コード例 #1
0
ファイル: CRMController.cs プロジェクト: harlov-va/st_publish
        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 = "Ошибка"
                });
            }
        }
コード例 #2
0
ファイル: CRMRepository.cs プロジェクト: harlov-va/st_publish
 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);
 }
コード例 #3
0
ファイル: CRMManager.cs プロジェクト: harlov-va/st_publish
        public crm_sources GetClientSource(int id)
        {
            var res = new crm_sources();

            res = db.GetClientSource(id);
            return(res);
        }
コード例 #4
0
ファイル: CRMRepository.cs プロジェクト: harlov-va/st_publish
        public crm_sources GetClientSource(int id)
        {
            var res = new crm_sources();

            res = db.crm_sources.FirstOrDefault(x => x.id == id);
            return(res);
        }
コード例 #5
0
ファイル: CRMManager.cs プロジェクト: harlov-va/st_publish
 public void SaveClientSources(crm_sources item)
 {
     try
     {
         db.SaveClientSources(item);
     }
     catch (Exception ex)
     {
         RDL.Debug.LogError(ex);
     }
 }