Example #1
0
        public object InsertExtend([FromBody] SupplierExtend obj)
        {
            var msg = new JMessage();

            try
            {
                var query = from a in _context.SupplierExtends
                            where a.ext_code == obj.ext_code
                            select a;
                if (query.Count() == 0)
                {
                    obj.created_time = DateTime.Now.Date;
                    _context.SupplierExtends.Add(obj);
                    _context.SaveChanges();
                    msg.Error = false;
                    msg.Title = "Thêm trường mở rộng thành công!";
                }
                else
                {
                    msg.Error = true;
                    msg.Title = "Mã trường mở rộng đã tồn tại!";
                }
                return(Json(msg));
            }
            catch
            {
                msg.Error = true;
                msg.Title = "Có lỗi xảy ra!";

                return(Json(msg));
            }

            //try
            //{
            //    obj.created_time = DateTime.Now.Date;
            //    _context.SupplierExtends.Add(obj);
            //    _context.SaveChanges();
            //    msg.Error = false;
            //    msg.Title = "Thêm thành công";
            //    return Json(msg);
            //}
            //catch (Exception ex)
            //{
            //    msg.Error = true;
            //    msg.Title = "Có lỗi xảy ra!";
            //    msg.Object = ex;
            //    return Json(msg);
            //}
        }
Example #2
0
        public object UpdateExtend([FromBody] SupplierExtend obj)
        {
            var msg = new JMessage();

            try
            {
                obj.updated_time = DateTime.Now.Date;
                _context.SupplierExtends.Update(obj);
                _context.SaveChanges();
                msg.Error = false;
                msg.Title = "Cập nhật thành công";
                return(Json(msg));
            }
            catch (Exception ex)
            {
                msg.Error  = true;
                msg.Title  = "Có lỗi xảy ra!";
                msg.Object = ex;
                return(Json(msg));
            }
        }