public async Task <Response> AddBilty(BiltyVM bilty, decimal[] dos) { var Dto = Mapper.Map <BiltyVM, Bilty>(bilty); _db.Bilties.Add(Dto); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); foreach (decimal donumber in dos) { BiltyToDo biltyToDoObj = new BiltyToDo(); biltyToDoObj.Biltyno = Dto.BiltyNo; biltyToDoObj.Donumber = donumber; _db.BiltyToDos.Add(biltyToDoObj); int resultDos = await _db.SaveChangesAsync(); } return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }
public async Task <Response> AddGood(GoodsTypeVM goods) { var goodsDto = Mapper.Map <GoodsTypeVM, GoodsType>(goods); GoodsType goodsExist = await _db.GoodsTypes.Where(x => x.Goods.Trim() == goods.Goods.Trim()).FirstOrDefaultAsync(); if (goodsExist != null) { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0)); } _db.GoodsTypes.Add(goodsDto); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }
public async Task <Response> AddContractType(ContractTypeVM contracttype) { var Dto = Mapper.Map <ContractTypeVM, ContractType>(contracttype); ContractType Exist = await _db.ContractTypes.Where(x => x.Type.Trim() == contracttype.Type.Trim()).FirstOrDefaultAsync(); if (Exist != null) { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0)); } _db.ContractTypes.Add(Dto); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }
public async Task <Response> AddVehicle(VehicleVM vehicle) { var vehicleDto = Mapper.Map <VehicleVM, vehicle>(vehicle); vehicle vehicleExist = await _db.vehicles.Where(x => x.RegNumber.Trim() == vehicle.RegNumber.Trim()).FirstOrDefaultAsync(); if (vehicleExist != null) { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0)); } _db.vehicles.Add(vehicleDto); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }
public async Task <Response> AddBank(BankVM bank) { var Dto = Mapper.Map <BankVM, Bank>(bank); Bank Exist = await _db.Banks.Where(x => x.Bank1.Trim() == bank.Bank1.Trim()).FirstOrDefaultAsync(); if (Exist != null) { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, 0)); } _db.Banks.Add(Dto); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }
public async Task <Response> AddDo(DorderVM dorder) { var Dto = Mapper.Map <DorderVM, Dorder>(dorder); Dorder Exist = await _db.Dorders.Where(x => x.DoNumber == dorder.DoNumber).FirstOrDefaultAsync(); if (Exist != null) { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, -1)); } _db.Dorders.Add(Dto); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }
public async Task <bool> Adduser(UserVM user) { var userDto = Mapper.Map <UserVM, User>(user); _db.Users.Add(userDto); int result = await _db.SaveChangesAsync(); if (result == 1) { return(true); } else { return(false); } }
public async Task <Response> AddSetting(Setting setting) { Setting Exist = await _db.Settings.FirstOrDefaultAsync(); if (Exist != null) { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoAlreadyExist, (int)Constant.httpStatus.NoContent, -1)); } _db.Settings.Add(Exist); int result = await _db.SaveChangesAsync(); if (result == 1) { // Mapper.Initialize(cfg => cfg.CreateMap<User, UserVM>()); return(GenericResponses <int> .ResponseStatus(false, Constant.MSGRecordFound, (int)Constant.httpStatus.Ok, result)); } else { return(GenericResponses <int> .ResponseStatus(true, Constant.MDGNoLoginFailed, (int)Constant.httpStatus.NoContent, result)); } }