public HttpResponseMessage AddTinhTrangBo([FromBody] TinhTrangBoRequest request) { var response = new TinhTrangBoResponse(); var tokendata = TokenBUS.tokenData(request, response, 1); if (response.IsError) { ChamSocBUS.AddTinhTrangBo(request, ref response); if (response.IsError) { return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { ChamSoc cs = ChamSocRepository.AddTinhTrangBo(request.Data); if (cs == null) { response.Errors.Add("Lỗi hệ thống, hãy chăm sóc bò trước khi đo đạc thông số"); response.IsError = true; } else { ChamSocBUS.UpdateCowState(request.Token, cs.MaBo, request.TinhTrang); response.Data = cs; } } } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage reportTinhTrangBo3([FromBody] ReportTinhTrangBoRequest request) { var response = new ReportTinhTrangBoResponse(); if (TokenBUS.tokenCheck(request, response, 3)) { ChamSocBUS.ReportTinhTrangBo(request, ref response); if (response.IsError) { return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { response.Data = ChamSocRepository.ReportTinhTrangBo(request.NgayBatDau); } } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage reportTinhTrangBo2([FromBody] ReportTinhTrangBoRequest request) { var response = new ReportTinhTrangBoResponse(); var tokendata = TokenBUS.tokenData(request, response, 2); if (!response.IsError) { ChamSocBUS.ReportTinhTrangBo(request, ref response); if (response.IsError) { return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { response.Data = ChamSocRepository.ReportTinhTrangBo(tokendata.AgencyId, request.NgayBatDau); } } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage AddChamSoc([FromBody] ChamSocRequest request) { var response = new ChamSocResponse(); var tokendata = TokenBUS.tokenData(request, response, 1); if (!response.IsError) { ChamSocBUS.AddChamSoc(request, ref response); if (response.IsError) { return(Request.CreateResponse(HttpStatusCode.OK, response)); } else { ChamSoc cs = ChamSocRepository.IsExistsChamSoc(request.Data); if (cs != null) { request.Data.MaChamSoc = cs.MaChamSoc; ChamSocBUS.UpdateChamSoc(request, ref response); if (response.IsError) { return(Request.CreateResponse(HttpStatusCode.OK, response)); } if (cs.LuongSua != request.Data.LuongSua) { if (!ChamSocBUS.UpdateMilk(request.Token, request.Data.LuongSua - cs.LuongSua)) { response.Errors.Add("Lỗi hệ thống"); response.IsError = true; return(Request.CreateResponse(HttpStatusCode.OK, response)); } } if (ChamSocRepository.Update(request.Data) < 0) { response.Errors.Add("Lỗi hệ thống"); response.IsError = true; } else { response.Data = "Sửa thành công!"; } } else { if (ChamSocBUS.UpdateMilk(request.Token, request.Data.LuongSua)) { request.Data.MaChiNhanh = tokendata.AgencyId; if (ChamSocRepository.Insert(request.Data) < 0) { response.Errors.Add("Lỗi hệ thống"); response.IsError = true; } else { response.Data = "Thêm thành công!"; } } else { response.Errors.Add("Lỗi hệ thống"); response.IsError = true; } } } } return(Request.CreateResponse(HttpStatusCode.OK, response)); }