Esempio n. 1
0
        public async Task <ResponseModel> Delete(TrainingCenterContactModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                TrainingCenterContact md = await _context.TrainingCenterContactRepository.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.TrainingCenterContactRepository.Update(md);

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

            try
            {
                TrainingCenterContact md = await _context.TrainingCenterContactRepository.FirstOrDefaultAsync(m => m.Id == id);

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

                TrainingCenterContactModel model = new TrainingCenterContactModel()
                {
                    Id               = md.Id,
                    Name             = md.Name,
                    Position         = md.Position,
                    Phone            = md.Phone,
                    Fax              = md.Fax,
                    Email            = md.Email,
                    TrainingCenterId = md.TrainingCenterId,
                    IsActive         = md.IsActive,
                    RowVersion       = md.RowVersion,
                };

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

            try
            {
                TrainingCenterContact md = new TrainingCenterContact();

                md.Name             = model.Name;
                md.Position         = model.Position;
                md.Phone            = model.Phone;
                md.Fax              = model.Fax;
                md.Email            = model.Email;
                md.TrainingCenterId = model.TrainingCenterId;
                md.IsActive         = model.IsActive;
                md.CreateBy         = base.UserId;
                md.CreateDate       = DateTime.Now;

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

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Esempio n. 4
0
        public async Task <ResponseModel> Delete([FromBody] TrainingCenterContactModel model)
        {
            var response = await _trainingCenterContactService.Delete(model);

            return(response);
        }