示例#1
0
        public ActionResult PartnersSpec_save()
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);
            var mng        = new PartnersManager();

            try
            {
                var fields         = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList();
                var newPartnerSpec = new ps_specs
                {
                    id   = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)),
                    name = (AjaxModel.GetValueFromSaveField("name", fields)),
                };

                mng.SavePartnersSpec(newPartnerSpec);
                return(Json(new
                {
                    result = true,
                    id = newPartnerSpec.id,
                    mng = "Операция прошла успешно"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
                return(Json(new
                {
                    result = false,
                    id = 0,
                    mng = "Ошибка"
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        public ps_specs GetPartnersSpec(int id)
        {
            var res = new ps_specs();

            res = db.GetPartnersSpec(id);
            return(res);
        }
示例#3
0
 public int SavePartnersSpec(ps_specs element)
 {
     try
     {
         if (element.id == 0)
         {
             db.ps_specs.Add(element);
             db.SaveChanges();
         }
         else
         {
             try
             {
                 db.Entry(element).State = EntityState.Modified;
                 db.SaveChanges();
             }
             catch (OptimisticConcurrencyException ex)
             {
                 RDL.Debug.LogError(ex);
             }
         }
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
     return(element.id);
 }
示例#4
0
        //
        public ps_specs GetPartnersSpec(int id)
        {
            var res = new ps_specs();

            res = db.ps_specs.FirstOrDefault(partner => partner.id == id);
            return(res);
        }
示例#5
0
 public void SavePartnersSpec(ps_specs item)
 {
     try
     {
         db.SavePartnersSpec(item);
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
 }
示例#6
0
        //
        public ps_specs GetPartnersSpec(int id, string name)
        {
            ps_specs res = db.ps_specs.FirstOrDefault(x => x.id == id && x.name == name);

            return(res);
        }