Exemplo n.º 1
0
        public ActionResult Sources_save()
        {
            var parameters = AjaxModel.GetAjaxParameters(HttpContext);
            var mng = new CRMManager();

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

                };
                mng.SaveClientSources(newSources);
                return Json(new 
                {
                    result = true,
                    id = newSources.id,
                    mng = "Операция прошла успешно"
                }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                RDL.Debug.LogError(ex);
                return Json(new 
                {
                    result = false,
                    id = 0,
                    mng = "Ошибка"
                });
            }
        }
Exemplo n.º 2
0
 public int SaveClientSources(crm_sources element)
 {
     try
     {
         if (element.id == 0)
         {
             db.crm_sources.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);
 }
Exemplo n.º 3
0
        public crm_sources GetClientSource(int id)
        {
            var res = new crm_sources();

            res = db.GetClientSource(id);
            return(res);
        }
Exemplo n.º 4
0
        public crm_sources GetClientSource(int id)
        {
            var res = new crm_sources();

            res = db.crm_sources.FirstOrDefault(x => x.id == id);
            return(res);
        }
Exemplo n.º 5
0
 public void SaveClientSources(crm_sources item)
 {
     try
     {
         db.SaveClientSources(item);
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
 }