public async Task <ResponseModel> Item(int id) { ResponseModel response = new ResponseModel(); try { RelationshipType md = await _context.RelationshipTypeRepository.FirstOrDefaultAsync(m => m.Id == id); RelationshipTypeModel model = new RelationshipTypeModel() { Id = md.Id, Name = md.Name, Precedence = md.Precedence, IsActive = md.IsActive, RowVersion = md.RowVersion, }; response.Result = model; } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Insert(RelationshipTypeModel model) { ResponseModel response = new ResponseModel(); try { RelationshipType md = new RelationshipType(); 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.RelationshipTypeRepository.AddAsync(md).ConfigureAwait(true); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Delete(RelationshipTypeModel model) { ResponseModel response = new ResponseModel(); try { RelationshipType md = await _context.RelationshipTypeRepository.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.RelationshipTypeRepository.Update(md); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(response); }
public async Task <ResponseModel> Delete([FromBody] RelationshipTypeModel model) { var response = await _relationshipTypeService.Delete(model); return(response); }