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

            try
            {
                AppraiseSection md = await _context.AppraiseSectionRepository.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.AppraiseSectionRepository.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
            {
                AppraiseSection md = await _context.AppraiseSectionRepository.FirstOrDefaultAsync(m => m.Id == id);

                if (md == null)
                {
                    throw new NullParameterException();
                }

                AppraiseSectionModel model = new AppraiseSectionModel()
                {
                    Id          = md.Id,
                    AppraiseId  = md.AppraiseId,
                    Name        = md.Name,
                    Description = md.Description,
                    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(AppraiseSectionModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                AppraiseSection md = new AppraiseSection();

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

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

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }