private SysColor SetToColorModel(Sys_Color entity)
        {
            var model = new SysColor();

            model.ColorID   = entity.ColorID;
            model.ColorName = entity.ColorName;
            model.ColorCode = entity.ColorCode;
            return(model);
        }
Beispiel #2
0
        public Sys_Color SetToModelObject(SysColor model, int userid)
        {
            Sys_Color entity = new Sys_Color();

            entity.ColorID   = model.ColorID;
            entity.ColorCode = model.ColorCode;
            entity.ColorName = model.ColorName;
            entity.IsActive  = model.IsActive == "Active";
            entity.SetOn     = DateTime.Now;
            entity.SetBy     = userid;
            entity.IPAddress = string.Empty;
            return(entity);
        }
Beispiel #3
0
        public ValidationMsg Save(SysColor model, int userid)
        {
            var vmMsg = new ValidationMsg();

            try
            {
                Sys_Color tblSysColor = SetToModelObject(model, userid);
                _context.Sys_Color.Add(tblSysColor);

                _context.SaveChanges();
                ColorID    = tblSysColor.ColorID;
                ColorCode  = model.ColorCode;
                vmMsg.Type = Enums.MessageType.Success;
                vmMsg.Msg  = "Saved Successfully.";
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.InnerException.Message.Contains("UNIQUE KEY"))
                    {
                        vmMsg.Type = Enums.MessageType.Error;
                        vmMsg.Msg  = "Color Code Already Exit.";
                    }
                    else
                    {
                        vmMsg.Type = Enums.MessageType.Error;
                        vmMsg.Msg  = "Failed to Save.";
                    }
                }
                else
                {
                    vmMsg.Type = Enums.MessageType.Error;
                    vmMsg.Msg  = "Failed to Save.";
                }
            }
            return(vmMsg);
        }
 public Sys_ColorCreateOrUpdateCommand(Sys_Color ent)
 {
     this.ent = ent;
 }