Skip to content

Commit

Permalink
Area Module - Add
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaithani committed Mar 12, 2023
1 parent ae2b8fd commit 8b20a20
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 9 deletions.
1 change: 1 addition & 0 deletions DAL/IUnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace DAL
{
public interface IUnitOfWork
{
IAreaMasterRepository AreaMaster { get; }
ICustomerRepository Customers { get; }
IProductRepository Products { get; }
IOrdersRepository Orders { get; }
Expand Down
8 changes: 0 additions & 8 deletions DAL/Models/AreaMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@ namespace DAL.Models
public class AreaMaster
{
public int Id { get; set; }

public int UserId { get; set; }

public string AreaCode { get; set; }

public string AreaDesc { get; set; }

public bool IsActive { get; set; }

public int? CreatedBy { get; set; }

public int? ModifiedBy { get; set; }

public DateTime? CreatedDate { get; set; }

public DateTime? ModidfiedDate { get; set; }
}
}
16 changes: 16 additions & 0 deletions DAL/Repositories/AreaMasterRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using DAL.Models;
using DAL.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL.Repositories
{
public class AreaMasterRepository : Repository<AreaMaster>, IAreaMasterRepository
{
public AreaMasterRepository(DbContext context) : base(context){ }
}
}
13 changes: 13 additions & 0 deletions DAL/Repositories/Interfaces/IAreaMasterRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using DAL.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL.Repositories.Interfaces
{
public interface IAreaMasterRepository : IRepository<AreaMaster>
{
}
}
11 changes: 11 additions & 0 deletions DAL/UnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class UnitOfWork : IUnitOfWork
{
readonly ApplicationDbContext _context;

IAreaMasterRepository _areaMaster;
ICustomerRepository _customers;
IProductRepository _products;
IOrdersRepository _orders;
Expand All @@ -29,6 +30,16 @@ public UnitOfWork(ApplicationDbContext context)
}


public IAreaMasterRepository AreaMaster
{
get
{
if (_areaMaster == null)
_areaMaster = new AreaMasterRepository(_context);

return _areaMaster;
}
}

public ICustomerRepository Customers
{
Expand Down
2 changes: 2 additions & 0 deletions QuickApp/ClientApp/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RouterModule, Routes, DefaultUrlSerializer, UrlSerializer, UrlTree } fr
import { LoginComponent } from './components/login/login.component';
import { HomeComponent } from './components/home/home.component';
import { CustomersComponent } from './components/customers/customers.component';
import { AreaComponent } from './components/area/area.component';
import { ProductsComponent } from './components/products/products.component';
import { OrdersComponent } from './components/orders/orders.component';
import { SettingsComponent } from './components/settings/settings.component';
Expand Down Expand Up @@ -45,6 +46,7 @@ const routes: Routes = [
{ path: '', component: HomeComponent, canActivate: [AuthGuard], data: { title: 'Home' } },
{ path: 'login', component: LoginComponent, data: { title: 'Login' } },
{ path: 'customers', component: CustomersComponent, canActivate: [AuthGuard], data: { title: 'Customers' } },
{ path: 'area', component: AreaComponent, canActivate: [AuthGuard], data: { title: 'Area' } },
{ path: 'products', component: ProductsComponent, canActivate: [AuthGuard], data: { title: 'Products' } },
{ path: 'orders', component: OrdersComponent, canActivate: [AuthGuard], data: { title: 'Orders' } },
{ path: 'settings', component: SettingsComponent, canActivate: [AuthGuard], data: { title: 'Settings' } },
Expand Down
4 changes: 3 additions & 1 deletion QuickApp/ClientApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { UserPreferencesComponent } from './components/controls/user-preferences
import { UsersManagementComponent } from './components/controls/users-management.component';
import { RolesManagementComponent } from './components/controls/roles-management.component';
import { RoleEditorComponent } from './components/controls/role-editor.component';
import { AreaComponent } from './components/area/area.component';


@NgModule({
Expand All @@ -82,7 +83,8 @@ import { RoleEditorComponent } from './components/controls/role-editor.component
EqualValidator,
AutofocusDirective,
BootstrapTabDirective,
GroupByPipe
GroupByPipe,
AreaComponent
],
imports: [
BrowserModule,
Expand Down
1 change: 1 addition & 0 deletions QuickApp/ClientApp/src/app/assets/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"New": "New"
},
"mainMenu": {
"Areas": "Areas",
"Appointments": "Appointments",
"Customers": "Customers",
"Products": "Products",
Expand Down
3 changes: 3 additions & 0 deletions QuickApp/ClientApp/src/app/components/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{ exact: true }">
<a class="nav-link" routerLink=""><i class="fa fa-home"></i></a>
</li>
<li class="nav-item" routerLinkActive="active" *ngIf="canViewCustomers">
<a class="nav-link" routerLink="/area">{{'mainMenu.Areas' | translate}}</a>
</li>
<li class="nav-item" routerLinkActive="active" *ngIf="canViewCustomers">
<a class="nav-link" routerLink="/customers">{{'mainMenu.Customers' | translate}}</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>area works!</p>
Empty file.
23 changes: 23 additions & 0 deletions QuickApp/ClientApp/src/app/components/area/area.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AreaComponent } from './area.component';

describe('AreaComponent', () => {
let component: AreaComponent;
let fixture: ComponentFixture<AreaComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AreaComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(AreaComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions QuickApp/ClientApp/src/app/components/area/area.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-area',
templateUrl: './area.component.html',
styleUrls: ['./area.component.scss']
})
export class AreaComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
43 changes: 43 additions & 0 deletions QuickApp/Controllers/AreaMasterController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using AutoMapper;
using DAL;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using QuickApp.Helpers;
using QuickApp.ViewModels;
using System.Collections.Generic;

namespace QuickApp.Controllers
{
[Route("api/[controller]")]
public class AreaMasterController : ControllerBase
{
private readonly IMapper _mapper;
private readonly IUnitOfWork _unitOfWork;
private readonly ILogger _logger;
private readonly IEmailSender _emailSender;

public AreaMasterController(IMapper mapper, IUnitOfWork unitOfWork, ILogger<CustomerController> logger, IEmailSender emailSender)
{
_mapper = mapper;
_unitOfWork = unitOfWork;
_logger = logger;
_emailSender = emailSender;
}

// GET: api/values
[HttpGet("{user}")]
public IActionResult Get(int user)
{
var allAreaMasters = _unitOfWork.AreaMaster.Find(x=>x.UserId== user);
return Ok(_mapper.Map<IEnumerable<AreaMasterViewModel>>(allAreaMasters));
}

// GET api/values/5
[HttpGet("{user}/{id}")]
public string Get(int user,int id)
{
return "value: " + user + id;
}
}
}
9 changes: 9 additions & 0 deletions QuickApp/ViewModels/AreaMasterViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace QuickApp.ViewModels
{
public class AreaMasterViewModel
{
public int Id { get; set; }
public string AreaCode { get; set; }
public string AreaDesc { get; set; }
}
}

0 comments on commit 8b20a20

Please sign in to comment.