コード例 #1
0
        public ActionResult Bireyler(Birey model)
        {
            Guid          recordId = Guid.Empty;
            CrmRepository crmDB    = RepositoryManager.GetRepository <CrmRepository>();

            #region Ortak Set Edilecek Değerler
            SessionContext.Current.ActiveUser.MenuId = model.MenuId;
            ViewBag.Success = true;
            #endregion

            model.activeKurumlar = crmDB.GetKurumList();

            ModelState.Remove("is_active");

            if (model.FromDeleteButton == "1")
            {
                if (GlobalHelper.IsGuid(model.RecordId))
                {
                    crmDB.DeleteBirey(model, Guid.Parse(model.RecordId));
                    return(RedirectToAction("ListPage", "General", new { MenuId = Dcm.Source.GlobalHelper.Encrypt(model.MenuId) }));
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (GlobalHelper.IsGuid(model.RecordId))
                    {
                        recordId = Guid.Parse(model.RecordId);
                        try
                        {
                            model = crmDB.UpdateBirey(model, recordId);

                            if (model.calistigi_kurum_id != null && GlobalHelper.IsGuidOrEmpty(model.calistigi_kurum_id))
                            {
                                model.calistigi_kurum_id = model.calistigi_kurum_id.ToString();
                            }

                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            crm_bireyler birey = new crm_bireyler();
                            crmDB.AddBirey(birey, model);
                            model.RecordId = birey.birey_id.ToString();
                            if (birey.calistigi_kurum_id != null)
                            {
                                model.calistigi_kurum_id = birey.calistigi_kurum_id.ToString();
                            }

                            ViewBag.ResultMessage = Resources.GlobalResource.transaction_success;
                        }
                        catch (Exception exp)
                        {
                            ViewBag.Success = false;
                            ModelState.AddModelError("Error", exp.Message);
                        }
                    }
                }
                else
                {
                    ViewBag.Success = false;
                }
            }

            return(View(model));
        }