Esempio n. 1
0
        public JsonResult Insert([FromBody] AssetActivity data)
        {
            var msg = new JMessage()
            {
                Error = false
            };

            try
            {
                var checkExist = _context.AssetAtivitys.FirstOrDefault(x => x.ActCode.ToLower() == data.ActCode.ToLower());
                if (checkExist != null)
                {
                    msg.Error = true;
                    msg.Title = "Đã tồn tại mã hoạt động!";
                }
                else
                {
                    data.CreatedBy   = ESEIM.AppContext.UserName;
                    data.CreatedTime = DateTime.Now;
                    _context.AssetAtivitys.Add(data);
                    _context.SaveChanges();
                    msg.Title = "Thêm hoạt động thành công";
                }
            }
            catch (Exception ex)
            {
                msg.Error = true;
                msg.Title = "Có lỗi xảy ra khi thêm?";
            }
            return(Json(msg));
        }
Esempio n. 2
0
        public object Update([FromBody] AssetActivity data)
        {
            var msg = new JMessage()
            {
                Error = false
            };

            try
            {
                data.UpdatedBy   = ESEIM.AppContext.UserName;
                data.UpdatedTime = DateTime.Now;
                _context.AssetAtivitys.Update(data);
                _context.SaveChanges();
                msg.Title = "Cập nhật hoạt động thành công";
            }
            catch (Exception ex)
            {
                msg.Error = true;
                msg.Title = "Có lỗi xảy ra khi cập nhật!";
            }
            return(Json(msg));
        }