コード例 #1
0
        public ActionResult GetOrnamentById(int ID)
        {
            string operation = Session["Operation"].ToString();

            ButtonVisiblity(operation);
            Mst_Ornament      tblOrnament = dd._context.Mst_Ornament.Where(x => x.Orn_Id == ID).FirstOrDefault();
            OrnamentViewModel ornament    = new OrnamentViewModel();

            ornament.ID           = tblOrnament.Orn_Id;
            ornament.OrnamentName = tblOrnament.Orn_Name;
            ornament.Product      = (short)tblOrnament.Orn_Product;
            ornament.Status       = (short)tblOrnament.Orn_Status;
            ornament.operation    = operation;
            return(View("Ornament", ornament));
        }
コード例 #2
0
        //[ValidateAntiForgeryToken]
        public JsonResult CreateEdit(OrnamentViewModel ornament)
        {
            ornament.CreatedBy = Convert.ToInt32(Session["UserLoginId"]);
            ornament.UpdatedBy = Convert.ToInt32(Session["UserLoginId"]);
            Mst_Ornament tblOrnament = new Mst_Ornament();

            try
            {
                if (ornament.ID <= 0)
                {
                    var data = dd._context.Mst_Ornament.Where(u => u.Orn_Name == ornament.OrnamentName).Select(x => x.Orn_Name).FirstOrDefault();
                    if (data != null)
                    {
                        ModelState.AddModelError("OrnamentName", "Ornament Name Already Exists");
                        return(Json(ornament));
                    }
                    tblOrnament.Orn_RecordCreated   = DateTime.Now;
                    tblOrnament.Orn_RecordCreatedBy = ornament.CreatedBy;
                    dd._context.Mst_Ornament.Add(tblOrnament);
                }
                else
                {
                    tblOrnament = dd._context.Mst_Ornament.Where(x => x.Orn_Id == ornament.ID).FirstOrDefault();
                }
                tblOrnament.Orn_Name            = ornament.OrnamentName;
                tblOrnament.Orn_Product         = ornament.Product;
                tblOrnament.Orn_Status          = ornament.Status;
                tblOrnament.Orn_RecordUpdated   = DateTime.Now;
                tblOrnament.Orn_RecordUpdatedBy = ornament.UpdatedBy;
                dd._context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(Json(ornament));
        }