Esempio n. 1
0
        public ActionResult Create(OperatorInformationVM viewModel)
        {
            try
            {
                var UserProfile = (UserProfileSessionData)this.Session["UserProfile"];
                if (UserProfile != null)
                {
                    if (ModelState.IsValid)
                    {
                        tbl_OperatorInformation item = new tbl_OperatorInformation()
                        {
                            OperatorType_EVID = viewModel.OperatorTypeEVID,
                            Name = viewModel.Name,
                            OperatorChanelType_EVID = viewModel.OperatorChanelTypeEVID,
                            InOutType_EVID          = viewModel.InOutTypeEVID,
                            Price      = viewModel.Price,
                            Point      = viewModel.Point,
                            InsertDate = DateTime.Now,
                            InsertUser = UserProfile.UserId
                        };
                        CRUDOperation dataOperations = new CRUDOperation();

                        tbl_OperatorInformation operatorInformationControl = dataOperations.ControlOperatorInformation(item);
                        if (operatorInformationControl != null)
                        {
                            TempData["success"] = "notOk";
                            TempData["message"] = "Eyni parametrelerə sahib məlumat sistemdə mövcudur";
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            tbl_OperatorInformation dbItem = dataOperations.AddOperatorInformation(item);
                            if (dbItem != null)
                            {
                                TempData["success"] = "Ok";
                                TempData["message"] = "Məlumatlar uğurla əlavə olundu";
                                return(RedirectToAction("Index"));
                            }
                            else
                            {
                                TempData["success"] = "notOk";
                                TempData["message"] = "Məlumatlar əlavə olunarkən xəta baş verdi";
                                return(RedirectToAction("Index"));
                            }
                        }
                    }
                }
                throw new ApplicationException("Invalid model");
            }

            catch (ApplicationException ex)
            {
                viewModel = poulateDropDownList(viewModel);

                return(View(viewModel));
            }
        }