public bool SaveEstimationProject(EstimationProjectModel model) { bool status = false; try { IUnitOfWork uwork = new UnitOfWork(); IEstimationRepository estimationRepository = new EstimationRepository(uwork); Utility.SetDynamicPropertyValue(model, model.CurrentCulture); var mapModel = Mapper.Map <EstimationProjectModel, EstimationProject>(model); if (model.ID == Guid.Empty) { mapModel.ID = Guid.NewGuid(); var result = estimationRepository.SaveEstimationProject(mapModel); if (result != null) { var estimations = estimationRepository.GetSelectedEstimationList(model.EstimationList); estimations.All(e => { e.ProjectID = result.ID; return(true); }); // var dbEstimations = Mapper.Map<List<Estimation>, List<EstimationModel>>(estimations); foreach (var estimation in estimations) { //SaveEstimation(estimation); estimationRepository.UpdateEstimation(estimation); } } } else { } status = true; } catch (Exception ex) { IErrorLogService errorLog = new ErrorLogService(); string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; errorLog.SetErrorLog(model.CurrentUserID, "Estimation", message); throw new Exception(message); } return(status); }
public HttpResponseMessage SaveTranslationEstimationsProject(EstimationProjectModel model) { try { if (this.ModelState.IsValid) { var result = _service.SaveEstimationProject(model); return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }