コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        // 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));
        }
コード例 #9
0
        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));
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        // GET: Industries/Create
        public ActionResult Create()
        {
            VmIndustryItem roleObj = new VmIndustryItem();

            return(View(roleObj));
        }