Exemple #1
0
        public ActionResult Create(CRMSalesStage cRMSalesStage)
        {
            if (ModelState.IsValid)
            {
                cRMSalesStage.CreatedByUserId = WebUser.Id;

                _crmSalesSalesStageRepository.Create(cRMSalesStage);
                _unitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(cRMSalesStage));
        }
        public ActionResult Update(CRMSalesStage salesStage)
        {
            ApiResult <CRMSalesStage> apiResult;

            if (ModelState.IsValid)
            {
                if (salesStage.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        var selectedSalesStage             = _crmSalesStageRepository.Get(salesStage.Id);
                        selectedSalesStage.Name            = salesStage.Name;
                        selectedSalesStage.Status          = salesStage.Status;
                        selectedSalesStage.UpdatedByUserId = WebUser.Id;
                        _crmSalesStageRepository.Update(selectedSalesStage);
                        _unitOfWork.Commit();
                        return(selectedSalesStage);
                    }, "Lead Source Period updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        var newSalesStage = new CRMSalesStage
                        {
                            Name            = salesStage.Name,
                            Status          = salesStage.Status,
                            CreatedByUserId = WebUser.Id
                        };
                        _crmSalesStageRepository.Create(newSalesStage);
                        _unitOfWork.Commit();
                        return(newSalesStage);
                    }, "Lead Source Period created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <CRMSalesStage>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }