Esempio n. 1
0
        public ActionResult Create(MdmWeightModel mdmWeights, bool continueEditing)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(AccessDeniedView());
            }
            var identity = ((CustomPrincipal)User).CustomIdentity;

            if (ModelState.IsValid)
            {
                MdmWeights mdmCat = new MdmWeights
                {
                    WEIGHT_ID     = mdmWeights.WEIGHT_ID,
                    WEIGHT_DESC   = mdmWeights.WEIGHT_DESC,
                    WEIGHT_VALUE  = mdmWeights.WEIGHT_VALUE,
                    CREATED_BY    = identity.ProfileId.ToString(),
                    CREATED_DATE  = DateTime.Now,
                    RECORD_STATUS = mdmWeights.RECORD_STATUS
                };
                db.MDM_WEIGHTS.Add(mdmCat);
                db.SaveChanges();
                db.Entry(mdmCat).GetDatabaseValues();

                //_localizationService.GetResource("Admin.Configuration.Stores.Added")
                SuccessNotification("New Weight has been Added");
                //do activity log
                return(continueEditing ? RedirectToAction("Edit", new { id = mdmCat.WEIGHT_ID }) : RedirectToAction("Index"));
                //return RedirectToAction("Index");
            }


            return(View(mdmWeights));
        }
Esempio n. 2
0
        // GET: MdmWeights/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MdmWeights mdmWeights = db.MDM_WEIGHTS.Find(id);

            if (mdmWeights == null)
            {
                return(HttpNotFound());
            }
            var model = new MdmWeightModel
            {
                WEIGHT_ID          = mdmWeights.WEIGHT_ID,
                WEIGHT_VALUE       = mdmWeights.WEIGHT_VALUE,
                WEIGHT_DESC        = mdmWeights.WEIGHT_DESC,
                CREATED_DATE       = mdmWeights.CREATED_DATE,
                CREATED_BY         = mdmWeights.CREATED_BY,
                LAST_MODIFIED_BY   = mdmWeights.LAST_MODIFIED_BY,
                LAST_MODIFIED_DATE = mdmWeights.LAST_MODIFIED_DATE
            };

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Edit(MdmWeightModel mdmWeight, bool continueEditing)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(AccessDeniedView());
            }
            var identity = ((CustomPrincipal)User).CustomIdentity;

            if (ModelState.IsValid)
            {
                using (var db = new AppDbContext())
                {
                    var entity = db.MDM_WEIGHTS.FirstOrDefault(o => o.WEIGHT_ID == mdmWeight.WEIGHT_ID);
                    if (entity == null)
                    {
                        string errorMessage = string.Format("Cannot update record with Id:{0} as it's not available.", mdmWeight.WEIGHT_ID);
                        ModelState.AddModelError("", errorMessage);
                    }
                    else
                    {
                        entity.WEIGHT_DESC        = mdmWeight.WEIGHT_DESC;
                        entity.WEIGHT_VALUE       = mdmWeight.WEIGHT_VALUE;
                        entity.RECORD_STATUS      = mdmWeight.RECORD_STATUS;
                        entity.LAST_MODIFIED_BY   = identity.ProfileId.ToString();
                        entity.LAST_MODIFIED_DATE = DateTime.Now;
                        db.MDM_WEIGHTS.Attach(entity);
                        db.Entry(entity).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }

                SuccessNotification("Item Updated");
                return(continueEditing ? RedirectToAction("Edit", new { id = mdmWeight.WEIGHT_ID }) : RedirectToAction("Index"));
                //return RedirectToAction("Index");
            }
            return(View(mdmWeight));
        }
Esempio n. 4
0
        // GET: MdmWeights/Create
        public ActionResult Create()
        {
            var model = new MdmWeightModel();

            return(View(model));
        }