Example #1
0
        public async Task <ResponseModel> Delete(ApproveStatusModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                ApproveStatus md = await _context.ApproveStatusRepository.FirstOrDefaultAsync(m => m.Id == model.Id);

                if (!md.RowVersion.SequenceEqual(model.RowVersion))
                {
                    response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.OutOfDateData;
                    return(response);
                }

                md.Deleted    = true;
                md.UpdateBy   = base.UserId;
                md.UpdateDate = DateTime.Now;

                _context.ApproveStatusRepository.Update(md);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Example #2
0
        public async Task <ResponseModel> Item(int id)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                ApproveStatus md = await _context.ApproveStatusRepository.FirstOrDefaultAsync(m => m.Id == id);

                ApproveStatusModel model = new ApproveStatusModel()
                {
                    Id         = md.Id,
                    Code       = md.Code,
                    Name       = md.Name,
                    Precedence = md.Precedence,
                    IsActive   = md.IsActive,
                    RowVersion = md.RowVersion,
                };

                response.Result = model;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Example #3
0
        public async Task <ResponseModel> Insert(ApproveStatusModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                if (await _context.ApproveStatusRepository.CountAsync(m => m.Code == model.Code) > 0)
                {
                    response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.CodeExists;
                    return(response);
                }

                ApproveStatus md = new ApproveStatus();

                md.Code       = model.Code;
                md.Name       = model.Name;
                md.Precedence = model.Precedence;
                md.IsActive   = model.IsActive;
                md.CreateBy   = base.UserId;
                md.CreateDate = DateTime.Now;

                await _context.ApproveStatusRepository.AddAsync(md).ConfigureAwait(true);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Example #4
0
        public static void BindStatus(ComboBox cbb)
        {
            IList <ApproveStatusModel> lstStock = new List <ApproveStatusModel>();
            ApproveStatusModel         obj      = new ApproveStatusModel();

            obj.StatusId   = 1;
            obj.StatusName = "Chờ xác nhận";
            lstStock.Add(obj);
            ApproveStatusModel obj1 = new ApproveStatusModel();

            obj1.StatusId   = 2;
            obj1.StatusName = "Đã xác nhận";
            lstStock.Add(obj1);
            ApproveStatusModel obj2 = new ApproveStatusModel();

            obj2.StatusId   = 3;
            obj2.StatusName = "Hủy bỏ";
            lstStock.Add(obj2);
            cbb.DataSource    = null;
            cbb.DataSource    = lstStock;
            cbb.DisplayMember = "StatusName";
            cbb.ValueMember   = "StatusId";
        }
        public async Task <ResponseModel> Delete([FromBody] ApproveStatusModel model)
        {
            var response = await _approveStatusService.Delete(model);

            return(response);
        }