public async Task <VmServiceTagsItem> GetFormObject() { VmServiceTagsItem result = new VmServiceTagsItem(); var dbCatList = await industryRepo.GetAll(); if (dbCatList == null) { return(result); } result.IndustryList = new List <VmIndustryItem>(); foreach (var dbcat in dbCatList) { VmIndustryItem _industry = new VmIndustryItem() { Id = dbcat.Id, Name = dbcat.Name }; result.IndustryList.Add(_industry); } return(result); }
public VmGenericServiceResult Insert(VmIndustryItem vmtem) { VmGenericServiceResult result = new VmGenericServiceResult(); try { Industry r = new Industry(); Copy <VmIndustryItem, Industry>(vmtem, r); if (r.CreatedBy.IsNullOrEmpty()) { r.CreatedBy = r.UpdatedBy = "System"; } repo.Add(r); repo.Commit(); result.IsSuccess = true; } catch (Exception e) { result.IsSuccess = false; result.Error = e; } return(result); }
public async Task <VmIndustryPage> GetIndustriesByPage(string keyword, int page, int totalRecords) { var dbPageResult = await repo.GetPage(keyword, (page == 0 ? Constants.app_firstPage : page), (totalRecords == 0 ? Constants.app_totalRecords : totalRecords)); if (dbPageResult == null) { return(new VmIndustryPage()); } var resultObj = new VmIndustryPage(); resultObj.RequestId = DateTime.Now.ToString("yyyyMMddHHmmss"); resultObj.RequestDate = DateTime.Now; resultObj.Result = new PageResult <VmIndustryItem>(); resultObj.Result.Records = new List <VmIndustryItem>(); Copy <PageResult <Industry>, PageResult <VmIndustryItem> >(dbPageResult, resultObj.Result, new string[] { "Records" }); foreach (var dbItem in dbPageResult.Records) { var resultItem = new VmIndustryItem(); Copy <Industry, VmIndustryItem>(dbItem, resultItem); resultObj.Result.Records.Add(resultItem); } return(resultObj); }
public async Task <VmGenericServiceResult> Update(VmIndustryItem vmtem) { VmGenericServiceResult result = new VmGenericServiceResult(); try { Industry r = await repo.Get(vmtem.Id); Copy <VmIndustryItem, Industry>(vmtem, r); if (r.UpdatedBy.IsNullOrEmpty()) { r.UpdatedBy = "System"; } repo.Update(r); repo.Commit(); result.IsSuccess = true; } catch (Exception e) { result.IsSuccess = false; result.Error = e; } return(result); }
public async Task <IActionResult> Create(VmIndustryItem industry) { var result = svs.Insert(industry); if (result.IsSuccess) { return(RedirectToAction(nameof(Index))); } else { ViewData["Error"] = result.Error.Message; return(View(industry)); } }
public async Task <VmIndustryItem> GetIndustryById(int Id) { var dbPageResult = await repo.Get(Id); if (dbPageResult == null) { return(new VmIndustryItem()); } var resultObj = new VmIndustryItem(); Copy <Industry, VmIndustryItem>(dbPageResult, resultObj); return(resultObj); }
public async Task <List <VmIndustryItem> > GetActiveIndustries() { var dbResult = await repo.GetAll(); var resultList = new List <VmIndustryItem>(); foreach (var item in dbResult) { var resultItem = new VmIndustryItem(); Copy <Industry, VmIndustryItem>(item, resultItem); resultList.Add(resultItem); } return(resultList); }
// GET: Industries/Edit/5 public async Task <ActionResult> Edit(int id) { if (id == null) { return(NotFound()); } int _id = (int)id; VmIndustryItem rItem = await svs.GetIndustryById(_id); if (rItem == null) { return(NotFound()); } return(View(rItem)); }
public async Task <ActionResult> Edit(int id, VmIndustryItem insustry) { if (id != insustry.Id) { return(NotFound()); } var result = await svs.Update(insustry); if (result.IsSuccess) { return(RedirectToAction(nameof(Index))); } else { return(View(insustry)); } }
public async Task <VmServiceTagsItem> GetServiceTagsById(int Id) { var dbPageResult = await repo.Get(Id); if (dbPageResult == null) { return(new VmServiceTagsItem()); } var resultObj = new VmServiceTagsItem(); Copy <Com.BudgetMetal.DBEntities.ServiceTags, VmServiceTagsItem>(dbPageResult, resultObj); var dbIndustryList = await industryRepo.GetAll(); if (dbIndustryList == null) { return(resultObj); } resultObj.IndustryList = new List <VmIndustryItem>(); foreach (var dbcat in dbIndustryList) { VmIndustryItem cat = new VmIndustryItem() { Id = dbcat.Id, Name = dbcat.Name }; resultObj.IndustryList.Add(cat); } return(resultObj); }
// GET: Industries/Create public ActionResult Create() { VmIndustryItem roleObj = new VmIndustryItem(); return(View(roleObj)); }