Exemplo n.º 1
0
        public ActionResult ManageStallCode(StallCodeModel stallCodeModel)
        {
            if (ModelState.IsValid)
            {
                using (var ctx = new LicenseApplicationContext())
                {
                    StallCode stallCode;
                    if (IsStallCodeDuplicate(stallCodeModel.StallCodeDesc, stallCodeModel.StallCodeID))
                    {
                        TempData["ErrorMessage"] = "Stall Code already exists in the database.";
                        return(View(stallCodeModel));
                    }

                    stallCode = Mapper.Map <StallCode>(stallCodeModel);
                    ctx.StallCodes.AddOrUpdate(stallCode);
                    ctx.SaveChanges();
                }

                TempData["SuccessMessage"] = "Stall Code saved successfully.";

                return(RedirectToAction("StallCode"));
            }
            else
            {
                return(View(stallCodeModel));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get StallCode Data by ID
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult ManageStallCode(int?Id)
        {
            StallCodeModel stallCodeModel = new StallCodeModel();

            stallCodeModel.Active = true;
            if (Id != null && Id > 0)
            {
                using (var ctx = new LicenseApplicationContext())
                {
                    int stallCodeID = Convert.ToInt32(Id);
                    var stallCode   = ctx.StallCodes.Where(a => a.StallCodeID == stallCodeID).FirstOrDefault();
                    stallCodeModel = Mapper.Map <StallCodeModel>(stallCode);
                }
            }

            return(View(stallCodeModel));
        }