コード例 #1
0
        public ActionResult Test(string task)
        {
            CodeCombinitionCreateViewModel model = new CodeCombinitionCreateViewModel();

            model.SOBId       = 18;
            model.SegmentList = getSegmentList(model.SOBId);

            if (task == "Update")
            {
                model.Id = 1;
            }

            model.Segment1 = "00003";    ////To be decided
            model.Segment2 = "0002";     ////To be decided
            model.Segment3 = "0001";     ////To be decided
            ////model.Segment4 = "";     ////To be decided
            ////model.Segment5 = "";     ////To be decided
            ////model.Segment6 = "";     ////To be decided
            ////model.Segment7 = "";     ////To be decided
            ////model.Segment8 = "";     ////To be decided
            model.StartDate      = new DateTime(2016, 1, 1);
            model.EndDate        = new DateTime(2016, 12, 31);
            model.AllowedPosting = true;

            if (ModelState.IsValid)
            {
                model.CompanyId = AuthenticationHelper.User.CompanyId;
                if (model.Id > 0)
                {
                    string result = service.Update(mapModel(model));
                }
                else
                {
                    string result = service.Insert(mapModel(model));
                }

                return(RedirectToAction("Index", model));
            }

            return(View(model));
        }
コード例 #2
0
        public static string SaveCodeCombination(CodeCombinitionCreateViewModel model)
        {
            List <CodeCombinition> codeCombinitions = service.GetAll(AuthenticationHelper.CompanyId.Value, SessionHelper.SOBId);

            if (model.Id > 0)
            {
                if (codeCombinitions.Where(rec => rec.Id != model.Id && rec.Segment1 == model.Segment1 && rec.Segment2 == model.Segment2 && rec.Segment3 == model.Segment3 && rec.Segment4 == model.Segment4 && rec.Segment5 == model.Segment5 && rec.Segment6 == model.Segment6 && rec.Segment7 == model.Segment7 && rec.Segment8 == model.Segment8).Any())
                {
                    return("Combinition already exists");
                }
                return(service.Update(getEntityByModel(model)));
            }
            else
            {
                if (codeCombinitions.Any())
                {
                    if (codeCombinitions.Where(rec => rec.Segment1 == model.Segment1 && rec.Segment2 == model.Segment2 && rec.Segment3 == model.Segment3 && rec.Segment4 == model.Segment4 && rec.Segment5 == model.Segment5 && rec.Segment6 == model.Segment6 && rec.Segment7 == model.Segment7 && rec.Segment8 == model.Segment8).Any())
                    {
                        return("Combinition already exists");
                    }
                }
                return(service.Insert(getEntityByModel(model)));
            }
        }