Exemplo n.º 1
0
        public IHttpActionResult AddPackage(tbl_Package item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            CRUDOperation operation = new CRUDOperation();
            tbl_Package   dbitem    = operation.AddPackage(item);

            return(Ok(dbitem));
        }
Exemplo n.º 2
0
        public ActionResult Create(PackageVM viewModel)
        {
            try
            {
                var UserProfile = (UserProfileSessionData)this.Session["UserProfile"];
                if (UserProfile != null)
                {
                    if (ModelState.IsValid)
                    {
                        tbl_Package item = new tbl_Package()
                        {
                            Mobile_EVID  = viewModel.Mobile_EVID,
                            PackageName  = viewModel.PackageName,
                            PackageSize  = viewModel.PackageSize,
                            Validity     = viewModel.Validity,
                            ValidityDesc = viewModel.ValidityDesc,
                            InsertDate   = DateTime.Now,
                            InsertUser   = UserProfile.UserId
                        };
                        CRUDOperation dataOperations = new CRUDOperation();
                        tbl_Package   dbItem         = dataOperations.AddPackage(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));
            }
        }