public HttpResponseMessage SaveUpdateStreetData(StreetVM streetVM) { var response = iStreetServiceService.SaveUpdateStreetData(streetVM); if (response.IsSuccess) { return(Request.CreateResponse(HttpStatusCode.OK, response, "application/json")); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, response, "application/json")); } }
public ResponseViewModel SaveUpdateStreetData(StreetVM streetVM) { try { if (streetVM.Id == 0) { //add if (streetVM != null) { Street data = new Street(); if (streetVM.UserType == UserType.Supervisor) { data.StreetName = streetVM.StreetName; data.CreatedBy = streetVM.CreatedBy; if (data != null) { streetRepository.Add(data); unitOfWork.Commit(); } if (data != null && data.Id > 0) { AssignStreet assginstreet = new AssignStreet(); assginstreet.StreetId = data.Id; assginstreet.SupervisorId = streetVM.CreatedBy; assignStreetRepository.Add(assginstreet); unitOfWork.Commit(); } } else { //data = Mapper.Map<Street>(streetVM); data.StreetName = streetVM.StreetName; data.CreatedBy = streetVM.CreatedBy; if (data != null) { streetRepository.Add(data); unitOfWork.Commit(); } } response.Status = "SUCCESS"; response.IsSuccess = true; response.Message = "Record Saved successfully..."; response.Content = null; } } else { //update } } catch (Exception ex) { response.IsSuccess = false; response.Status = "FAILED"; response.Content = null; if (response.ReturnMessage == null) { response.ReturnMessage = new List <string>(); } response.ReturnMessage.Add(ex.Message); } return(response); }