public BaseResponse RemoveClient(RemoveClientRequest request) { return(ServiceProcessor.ProcessRequest(request, //inbound.do validate or do something here () => { }, req => { var response = new BaseResponse(); using (var repo = new NhRepository <Client>()) { foreach (var id in req.Ids) { var entity = repo.GetById(id); if (entity != null) { repo.Delete(entity); } } } return response; } )); }
public BaseResponse UpdateCourt(UpdateCourtRequest request) { return(ServiceProcessor.ProcessRequest(request, //inbound.do validate or do something here () => { }, req => { var response = new BaseResponse(); using (var repo = new NhRepository <Court>()) { var entity = repo.GetById(req.Id); if (entity == null) { throw new EeException(ErrorCodes.NotFound, "Object is not found."); } entity.Name = req.Name; entity.Rank = req.Rank; entity.Province = req.Province; entity.City = req.City; entity.County = req.County; entity.Address = req.Address; entity.ContactNo = req.ContactNo; repo.Update(entity); } return response; } )); }
public BaseResponse UpdateClient(UpdateClientRequest request) { return(ServiceProcessor.ProcessRequest(request, //inbound.do validate or do something here () => { }, req => { var response = new BaseResponse(); using (var repo = new NhRepository <Client>()) { var entity = repo.GetById(req.Id); if (entity == null) { throw new EeException(ErrorCodes.NotFound, "Object is not found."); } entity.Name = req.Name; //TODO: repo.Update(entity); } return response; } )); }
public void DeleteTest() { using (var session = SessionManager.GetConnection()) { using (var repo = new NhRepository <Court>()) { var entity = repo.GetById(3); if (entity != null) { repo.Delete(entity); } } } }
public void UpdateTest() { using (var session = SessionManager.GetConnection()) { using (var repo = new NhRepository <Court>()) { var entity = repo.GetById(1); if (entity != null) { entity.Name = "new-Name" + DateTime.Now; repo.Update(entity); } } } }