Пример #1
0
        public ValidationMsg Update(SysUnit objSysUnit, int userid)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                var unit = _context.Sys_Unit.FirstOrDefault(s => s.UnitID == objSysUnit.UnitID);
                if (unit != null)
                {
                    unit.UnitName     = objSysUnit.UnitName;
                    unit.UnitCategory = objSysUnit.UnitCategory;
                    unit.IsActive     = objSysUnit.IsActive == "Active";
                    unit.IsDelete     = Convert.ToBoolean(objSysUnit.IsDelete);
                }
                _context.SaveChanges();

                _vmMsg.Type = Enums.MessageType.Update;
                _vmMsg.Msg  = "Updated Successfully.";
            }
            catch (Exception)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to record updated.";
            }
            return(_vmMsg);
        }
Пример #2
0
        public ValidationMsg Save(SysUnit objSysUnit, int userid)
        {
            _vmMsg = new ValidationMsg();
            try
            {
                var tblSysUnit = new Sys_Unit
                {
                    UnitID       = objSysUnit.UnitID,
                    UnitName     = objSysUnit.UnitName,
                    UnitCategory = objSysUnit.UnitCategory,
                    IsActive     = objSysUnit.IsActive == "Active",
                    IsDelete     = false,
                    SetOn        = DateTime.Now,
                    SetBy        = Convert.ToInt32(25),
                    ModifiedOn   = DateTime.Now,
                    ModifiedBy   = Convert.ToInt32(25),
                    IPAddress    = string.Empty
                };

                _context.Sys_Unit.Add(tblSysUnit);
                _context.SaveChanges();
                unitId      = objSysUnit.UnitID;
                _vmMsg.Type = Enums.MessageType.Success;
                _vmMsg.Msg  = "Saved Successfully.";
            }
            catch (Exception)
            {
                _vmMsg.Type = Enums.MessageType.Error;
                _vmMsg.Msg  = "Failed to Save.";
            }

            return(_vmMsg);
        }
Пример #3
0
 public ActionResult Unit(SysUnit model)
 {
     if (model != null && model.UnitID != 0)
     {
         _vmMsg = _dalSysUnit.Update(model, Convert.ToInt32(Session["UserID"]));
     }
     else
     {
         _vmMsg = _dalSysUnit.Save(model, Convert.ToInt32(Session["UserID"]));
     }
     return(Json(new { SourceID = _dalSysUnit.GetUnitID(), msg = _vmMsg }));
 }