public ReasonViewModel SetRecordinEdit(Mst_Reason tblReason)
        {
            ReasonViewModel reason = new ReasonViewModel();

            reason.ID         = tblReason.Re_No;
            reason.ReasonName = tblReason.Re_Desc;
            reason.Status     = (short)tblReason.Re_Status;
            return(reason);
        }
Esempio n. 2
0
        public ActionResult GetReasonById(int ID)
        {
            string operation = Session["Operation"].ToString();

            ButtonVisiblity(operation);
            Mst_Reason      tblReason = dd._context.Mst_Reason.Where(x => x.Re_No == ID).FirstOrDefault();
            ReasonViewModel reason    = new ReasonViewModel();

            reason.ID         = tblReason.Re_No;
            reason.ReasonName = tblReason.Re_Desc;
            reason.Status     = (short)tblReason.Re_Status;
            reason.operation  = operation;
            return(View("Reason", reason));
        }
        public void SaveUpdateRecord(ReasonViewModel reason)
        {
            Mst_Reason tblReason = new Mst_Reason();

            if (reason.ID <= 0)
            {
                tblReason.Re_RecordCreated   = DateTime.Now;
                tblReason.Re_RecordCreatedBy = reason.CreatedBy;
                _context.Mst_Reason.Add(tblReason);
            }
            else
            {
                tblReason = _context.Mst_Reason.Where(x => x.Re_No == reason.ID).FirstOrDefault();
            }
            tblReason.Re_Desc            = reason.ReasonName;
            tblReason.Re_Status          = reason.Status;
            tblReason.Re_RecordUpdated   = DateTime.Now;
            tblReason.Re_RecordUpdatedBy = reason.UpdatedBy;
            _context.SaveChanges();
        }
Esempio n. 4
0
        public JsonResult CreateEdit(ReasonViewModel reason)
        {
            reason.CreatedBy = Convert.ToInt32(Session["UserLoginId"]);
            reason.UpdatedBy = Convert.ToInt32(Session["UserLoginId"]);
            Mst_Reason tblReason = new Mst_Reason();

            try
            {
                if (reason.ID <= 0)
                {
                    var data = dd._context.Mst_Reason.Where(u => u.Re_Desc == reason.ReasonName).Select(x => x.Re_Desc).FirstOrDefault();
                    if (data != null)
                    {
                        ModelState.AddModelError("Reason", "Reason Already Exists");
                        return(Json(reason));
                    }
                    tblReason.Re_RecordCreated   = DateTime.Now;
                    tblReason.Re_RecordCreatedBy = reason.CreatedBy;
                    dd._context.Mst_Reason.Add(tblReason);
                }
                else
                {
                    tblReason = dd._context.Mst_Reason.Where(x => x.Re_No == reason.ID).FirstOrDefault();
                }
                tblReason.Re_Desc            = reason.ReasonName;
                tblReason.Re_Status          = reason.Status;
                tblReason.Re_RecordUpdated   = DateTime.Now;
                tblReason.Re_RecordUpdatedBy = reason.UpdatedBy;
                dd._context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(Json(reason));
        }
Esempio n. 5
0
        public ReasonViewModel SetDataOnEdit(Mst_Reason tblReason)
        {
            var item = _reasonRepository.SetRecordinEdit(tblReason);

            return(item);
        }