コード例 #1
0
        public IActionResult PriceCol_Edit(int id = 0, int priceDesc = 0)
        {
            PriceCol model = (id > 0) ? service.GetById <PriceCol>(id) : new PriceCol()
            {
                PriceDescId = priceDesc, Active = true
            };

            SetViewBag_PriceCol();
            return(View(model));
        }
コード例 #2
0
        public bool PriceDesc_Clone(int id, int?courtId)
        {
            try
            {
                var sourcePrice = repo.AllReadonly <PriceDesc>().Where(x => x.Id == id).Include(x => x.PriceCols).Include(x => x.PriceCols.Select(v => v.PriceVals)).FirstOrDefault();
                var price       = new PriceDesc()
                {
                    CourtId  = courtId,
                    Keyword  = sourcePrice.Keyword,
                    Name     = sourcePrice.Name,
                    DateFrom = sourcePrice.DateFrom,
                    DateTo   = sourcePrice.DateTo
                };

                foreach (var col in sourcePrice.PriceCols.OrderBy(x => x.OrderBy))
                {
                    var _col = new PriceCol()
                    {
                        Name    = col.Name,
                        ColType = col.ColType,
                        ColNo   = col.ColNo,
                        Active  = col.Active
                    };

                    foreach (var val in col.PriceVals)
                    {
                        var _val = new PriceVal()
                        {
                            RowNo = val.RowNo,
                            Value = val.Value,
                            Text  = val.Text
                        };
                        _col.PriceVals.Add(_val);
                    }

                    price.PriceCols.Add(_col);
                }


                repo.Add <PriceDesc>(price);
                repo.SaveChanges();
                foreach (var col in price.PriceCols)
                {
                    col.OrderBy = col.Id;
                    repo.Update <PriceCol>(col);
                    repo.SaveChanges();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #3
0
 public IActionResult PriceCol_Edit(PriceCol model)
 {
     if (!ModelState.IsValid)
     {
         SetViewBag_PriceCol();
         return(View(model));
     }
     if (service.PriceCol_SaveData(model))
     {
         SetSuccessMessage(MessageConstant.Values.SaveOK);
         return(RedirectToAction(nameof(PriceCol), new { priceDesc = model.PriceDescId }));
     }
     else
     {
         SetErrorMessage(MessageConstant.Values.SaveFailed);
         SetViewBag_PriceCol();
         return(View(model));
     }
 }
コード例 #4
0
 public bool PriceCol_SaveData(PriceCol model)
 {
     try
     {
         if (model.Id > 0)
         {
             repo.Update(model);
         }
         else
         {
             repo.Add(model);
             repo.SaveChanges();
             model.OrderBy = model.Id;
         }
         repo.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         logger.LogError(ex, "Грешка при запис на PriceCol_SaveData");
         return(false);
     }
 }