public async Task <Response> RemoveDo(DorderVM dorder) { try { var DTO = await _db.Dorders.Where(x => x.DoNumber == dorder.DoNumber).FirstOrDefaultAsync(); _db.Dorders.Remove(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.MSGFailed, (int)Constant.httpStatus.NoContent, result)); } } catch (Exception e) { return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0)); } }
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 <Response> updateDo(DorderVM dorder) { try { Dorder DTO = Mapper.Map <DorderVM, Dorder>(dorder); _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)); } } catch (Exception e) { return(GenericResponses <int> .ResponseStatus(true, e.Message, (int)Constant.httpStatus.NoContent, 0)); } }
public async Task <JsonResult> RemoveDo(DorderVM dorder) { Response r = await _Repository.RemoveDo(dorder); // List<UserVM> employees = ((IEnumerable)r.Value).Cast<UserVM>().ToList(); ; return(Json(r, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> AddDo() { IContractTypeRepository _repo = new ContractTypeRepository(); Response result = await _repo.GetallContractTrypes(); List <ContractTypeVM> list = ((IEnumerable)result.Value).Cast <ContractTypeVM>().ToList(); var selectListItems = list.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Type }).ToList(); ViewBag.LstContractType = selectListItems; ICityRepository _repocity = new CityRepository(); Response resultcity = await _repocity.GetALLCities(); List <CityVM> listcity = ((IEnumerable)resultcity.Value).Cast <CityVM>().ToList(); var selectListItemscity = listcity.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.City1 }).ToList(); ViewBag.LstCities = selectListItemscity; IPartyRepository _repoparty = new PartyRepository(); Response resultparty = await _repoparty.GetALLParties(); List <PartyVM> listparty = ((IEnumerable)resultparty.Value).Cast <PartyVM>().ToList(); var selectListItemsparty = listparty.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Party1 }).ToList(); ViewBag.LstParty = selectListItemsparty; IGoodsRepository _repogoods = new GoodsRepository(); Response resultgoods = await _repogoods.GetALLGoods(); List <GoodsTypeVM> listgoods = ((IEnumerable)resultgoods.Value).Cast <GoodsTypeVM>().ToList(); var selectListItemsgoods = listgoods.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Goods }).ToList(); ViewBag.LstGoods = selectListItemsgoods; Response resultUnits = _repogoods.GetallUnits(); List <DropDownListModel> listunits = ((IEnumerable)resultUnits.Value).Cast <DropDownListModel>().ToList(); var selectListUnits = listunits.Select(x => new SelectListItem() { Value = x.Value.ToString(), Text = x.Text }).ToList(); ViewBag.LstUnits = selectListUnits; ISettingRepository _setting = new SettingRepository(); DorderVM Do = new DorderVM(); bool autoInc = _setting.GetDoAutoIncrement(); if (autoInc) { Do.DoNumber = (_setting.GetLastDoNumber() + 1); } else { Do.DoNumber = _setting.GetLastDoNumber(); } Do.ContractNumber = _setting.GetLastContractNumber(); ViewBag.isAutoIncrement = autoInc; Do.BagsPerWeight = _setting.GetPackPerWeight(); return(View(Do)); }
public async Task <ActionResult> AddDo(DorderVM dorder, FormCollection frm) { int saveCopy = Convert.ToInt32(frm["SaveCopy"]); decimal lastDoNumber = 0; decimal lastContractNumber = 0; double totalQty = 0; int party = (int)dorder.Party; if (saveCopy == 1) { dorder.EcomID = (int)Session["Comp"]; dorder.CreatedOn = DateTime.Today; lastDoNumber = (decimal)dorder.DoNumber; lastContractNumber = (decimal)dorder.ContractNumber; Response reslut = await _Repository.AddDo(dorder); totalQty = (double)dorder.Weight; if (!reslut.IsError) { ISettingRepository _setting = new SettingRepository(); _setting.UpdateDoAutoIncrement(dorder.autoincrement); _setting.UpdateLastContractNumber((decimal)dorder.ContractNumber); _setting.UpdateLastDoNumber((lastDoNumber + 1)); IContractRespository _contract = new ContractRepository(); ContractVM contract = new ContractVM(); contract.Party = party; contract.PartyName = dorder.PartyName; contract.TotatQty = totalQty; contract.Unit = dorder.Unit; contract.EcomID = (int)Session["Comp"]; contract.CreatedOn = DateTime.Today; contract.ContractType = dorder.ContractType; contract.ContractNo = dorder.ContractNumber; if (_contract.isInsertable(contract)) { await _contract.AddContract(contract); } else { await _contract.UpdateContractQty(contract); } IAddressHistoryRepository _addresHistory = new AddressHistoryRepository(); AdressHistory addressHistory = new AdressHistory(); addressHistory.Party = dorder.Party; addressHistory.EnglisgAddress = dorder.AddressEng; addressHistory.UrduAddress = dorder.AddressUrd; if (_addresHistory.isInsertable((int)addressHistory.Party)) { _addresHistory.AddAddressHistory(addressHistory); } else { _addresHistory.updqateAddressHistory(addressHistory); } } } else { lastDoNumber = (decimal)dorder.DoNumber; for (int i = 0; i < saveCopy; i++) { dorder.EcomID = (int)Session["Comp"]; dorder.CreatedOn = DateTime.Today; dorder.DoNumber = lastDoNumber; lastContractNumber = (decimal)dorder.ContractNumber; Response reslutloop = await _Repository.AddDo(dorder); totalQty = totalQty + (double)dorder.Weight; lastDoNumber++; } ISettingRepository _setting = new SettingRepository(); _setting.UpdateDoAutoIncrement(dorder.autoincrement); _setting.UpdateLastContractNumber((decimal)dorder.ContractNumber); _setting.UpdateLastDoNumber((lastDoNumber)); IContractRespository _contract = new ContractRepository(); ContractVM contract = new ContractVM(); contract.Party = party; contract.PartyName = dorder.PartyName; contract.TotatQty = totalQty; contract.Unit = dorder.Unit; contract.EcomID = (int)Session["Comp"]; contract.CreatedOn = DateTime.Today; contract.ContractType = dorder.ContractType; contract.ContractNo = dorder.ContractNumber; if (_contract.isInsertable(contract)) { await _contract.AddContract(contract); } else { await _contract.UpdateContractQty(contract); } IAddressHistoryRepository _addresHistory = new AddressHistoryRepository(); AdressHistory addressHistory = new AdressHistory(); addressHistory.Party = dorder.Party; addressHistory.EnglisgAddress = dorder.AddressEng; addressHistory.UrduAddress = dorder.AddressUrd; if (_addresHistory.isInsertable((int)addressHistory.Party)) { _addresHistory.AddAddressHistory(addressHistory); } else { _addresHistory.updqateAddressHistory(addressHistory); } } return(RedirectToAction("Index")); }