public JsonResult Insert([FromBody] DocumentModel obj)
        {
            var msg = new JMessage {
                Title = "", Error = false
            };

            try
            {
                var data = _context.DispatchesCategorys.FirstOrDefault(x => x.Code == obj.Code && x.Type == EnumHelper <DocumentTypeEnum> .GetDisplayValue(DocumentTypeEnum.SVB) && x.IsDeleted == false);
                if (data == null)
                {
                    var dt = new DispatchesCategory();
                    dt.Code        = obj.Code;
                    dt.Name        = obj.Name;
                    dt.CreatedBy   = ESEIM.AppContext.UserName;
                    dt.CreatedTime = DateTime.Now;
                    dt.IsDeleted   = false;
                    dt.Type        = EnumHelper <DocumentTypeEnum> .GetDisplayValue(DocumentTypeEnum.SVB);

                    dt.DocumentType   = obj.DocumentType;
                    dt.NumberCreator  = obj.NumberCreator;
                    dt.DocumentSymbol = obj.DocumentSymbol;
                    dt.IsYearBefore   = obj.IsYearBefore;
                    dt.Year           = DateTime.Now.Year;
                    dt.TypeM          = obj.TypeM;
                    _context.DispatchesCategorys.Add(dt);
                    _context.SaveChanges();
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("DCD_MSG_TITLE_DCD"));
                }
                else
                {
                    msg.Error = true;
                    msg.Title = String.Format(CommonUtil.ResourceValue("DCD_MSG_DOCUMENT_NOT"));
                }
            }
            catch
            {
                msg.Error = true;
                msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED"), CommonUtil.ResourceValue("DCD_MSG_TITLE_DCD"));
            }
            return(Json(msg));
        }
Пример #2
0
        public JsonResult Insert([FromBody] DocumentTypeModel obj)
        {
            var msg = new JMessage {
                Title = "", Error = false
            };

            try
            {
                var data = _context.DispatchesCategorys.FirstOrDefault(x => x.Code == obj.Code && x.Type == EnumHelper <DocumentTypeEnum> .GetDisplayValue(DocumentTypeEnum.LVB) && x.IsDeleted == false);
                if (data == null)
                {
                    var dt = new DispatchesCategory();
                    dt.Code        = obj.Code;
                    dt.Name        = obj.Name;
                    dt.CreatedBy   = ESEIM.AppContext.UserName;
                    dt.CreatedTime = DateTime.Now;
                    dt.IsDeleted   = false;
                    dt.Type        = EnumHelper <DocumentTypeEnum> .GetDisplayValue(DocumentTypeEnum.LVB);

                    dt.ExpriedProcess = obj.ExpriedProcess;
                    _context.DispatchesCategorys.Add(dt);
                    _context.SaveChanges();
                    msg.Title = "Thêm loại văn bản thành công";
                }
                else
                {
                    msg.Error = true;
                    msg.Title = "Loại văn bản này đã tồn tại, vui lòng nhập mã khác!";
                }
            }
            catch
            {
                msg.Error = true;
                msg.Title = "Thêm loại văn bản bị lỗi!";
            }
            return(Json(msg));
        }
Пример #3
0
        public JsonResult Insert([FromBody] CategoryModel obj)
        {
            var msg = new JMessage {
                Title = "", Error = false
            };

            try
            {
                var data = _context.DispatchesCategorys.FirstOrDefault(x => x.Code == obj.Code && x.Type == EnumHelper <DocumentTypeEnum> .GetDisplayValue(DocumentTypeEnum.DM) && x.IsDeleted == false);
                if (data == null)
                {
                    var dt = new DispatchesCategory();
                    dt.Code        = obj.Code;
                    dt.Name        = obj.Name;
                    dt.CreatedBy   = ESEIM.AppContext.UserName;
                    dt.CreatedTime = DateTime.Now;
                    dt.IsDeleted   = false;
                    dt.Type        = EnumHelper <DocumentTypeEnum> .GetDisplayValue(DocumentTypeEnum.DM);

                    _context.DispatchesCategorys.Add(dt);
                    _context.SaveChanges();
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("DDC_MSG_TITLE_DDC"));
                }
                else
                {
                    msg.Error = true;
                    msg.Title = String.Format(CommonUtil.ResourceValue("DDC_ERR_DOCUMENT_CODE"));
                }
            }
            catch (Exception ex)
            {
                msg.Error = true;
                msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_FAILED"), CommonUtil.ResourceValue("DDC_MSG_TITLE_DDC"));
            }
            return(Json(msg));
        }