Beispiel #1
0
        public ValidationMsg Create(SysArticle objSysArticle, int userid)
        {
            var vmMsg = new ValidationMsg();

            try
            {
                var tblSysArticle = new Sys_Article
                {
                    ArticleID        = objSysArticle.ArticleID,
                    ArticleName      = objSysArticle.ArticleName,
                    ArticleNo        = objSysArticle.ArticleNo,
                    ArticleColor     = objSysArticle.ArticleColor,
                    ArticleChallanNo = objSysArticle.ArticleChallanNo,
                    IsActive         = objSysArticle.IsActive == "Active",
                    ArticleCategory  = objSysArticle.ArticleCategory,
                    Remarks          = objSysArticle.Remarks,
                    SetOn            = DateTime.Now,
                    SetBy            = userid,
                    IPAddress        = GetIPAddress.LocalIPAddress()
                };

                _context.Sys_Article.Add(tblSysArticle);
                _context.SaveChanges();
                ArticleId  = tblSysArticle.ArticleID;
                vmMsg.Type = Enums.MessageType.Success;
                vmMsg.Msg  = "Saved Successfully.";
            }
            catch (Exception ex)
            {
                vmMsg.Type = Enums.MessageType.Error;
                vmMsg.Msg  = "Failed to Save.";
            }
            return(vmMsg);
        }
        private SysArticle SetToArticleModel(Sys_Article entity)
        {
            var model = new SysArticle();

            model.ArticleID   = entity.ArticleID;
            model.ArticleName = entity.ArticleName;
            model.ArticleNo   = entity.ArticleNo;
            return(model);
        }