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 async Task <VmGenericServiceResult> Update(VmServiceTagsItem vmtem) { VmGenericServiceResult result = new VmGenericServiceResult(); try { Com.BudgetMetal.DBEntities.ServiceTags r = await repo.Get(vmtem.Id); Copy <VmServiceTagsItem, Com.BudgetMetal.DBEntities.ServiceTags>(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 VmGenericServiceResult Insert(VmServiceTagsItem vmtem) { VmGenericServiceResult result = new VmGenericServiceResult(); try { Com.BudgetMetal.DBEntities.ServiceTags r = new Com.BudgetMetal.DBEntities.ServiceTags(); Copy <VmServiceTagsItem, Com.BudgetMetal.DBEntities.ServiceTags>(vmtem, r); if (r.CreatedBy.IsNullOrEmpty()) { r.CreatedBy = r.UpdatedBy = "System"; } // r.Industry_Id = 1;//hard code repo.Add(r); repo.Commit(); result.IsSuccess = true; } catch (Exception e) { result.IsSuccess = false; result.Error = e; } return(result); }
public async Task <IActionResult> Create(VmServiceTagsItem serviceTagsItem) { var result = svs.Insert(serviceTagsItem); if (result.IsSuccess) { return(RedirectToAction(nameof(Index))); } else { return(View(serviceTagsItem)); } }
// GET: ServiceTags/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } int _id = (int)id; VmServiceTagsItem rItem = await svs.GetServiceTagsById(_id); if (rItem == null) { return(NotFound()); } return(View(rItem)); }
public async Task <List <VmServiceTagsItem> > GetActiveVmServiceTags() { var dbResult = await repo.GetServiceTagsByIndustry(0); var resultList = new List <VmServiceTagsItem>(); foreach (var item in dbResult) { var resultItem = new VmServiceTagsItem(); Copy <Com.BudgetMetal.DBEntities.ServiceTags, VmServiceTagsItem>(item, resultItem); resultList.Add(resultItem); } return(resultList); }
public async Task <ActionResult> Edit(int id, VmServiceTagsItem _serviceTags) { if (id != _serviceTags.Id) { return(NotFound()); } var result = await svs.Update(_serviceTags); if (result.IsSuccess) { return(RedirectToAction(nameof(Index))); } else { return(View(_serviceTags)); } }
public async Task <VmServiceTagsPage> GetServiceTagsByPage(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 VmServiceTagsPage()); } var resultObj = new VmServiceTagsPage(); resultObj.RequestId = DateTime.Now.ToString("yyyyMMddHHmmss"); resultObj.RequestDate = DateTime.Now; resultObj.Result = new PageResult <VmServiceTagsItem>(); resultObj.Result.Records = new List <VmServiceTagsItem>(); Copy <PageResult <Com.BudgetMetal.DBEntities.ServiceTags>, PageResult <VmServiceTagsItem> >(dbPageResult, resultObj.Result, new string[] { "Records" }); foreach (var dbItem in dbPageResult.Records) { var resultItem = new VmServiceTagsItem(); Copy <Com.BudgetMetal.DBEntities.ServiceTags, VmServiceTagsItem>(dbItem, resultItem); if (dbItem.Industry != null) { resultItem.Industry = new ViewModels.Industries.VmIndustryItem() { Name = dbItem.Industry.Name }; } resultObj.Result.Records.Add(resultItem); } return(resultObj); }
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); }