public List <QuotaionDetailsDM> GetAllQuotationDetails(int ID) { var QuotationDetails = _DbContext.QuotationDetails.Where(s => s.QuotationID == ID); List <QuotaionDetailsDM> QuotaionDetailsDMList = new List <QuotaionDetailsDM>(); if (QuotationDetails != null) { foreach (var item in QuotationDetails) { QuotaionDetailsDM QuotDetailsDM = new QuotaionDetailsDM(_GlobalErrors); QuotDetailsDM.ID = item.ID; QuotDetailsDM.NumberOfDays = item.NumberOfDays; QuotDetailsDM.Price = item.Price; QuotDetailsDM.Quotaion = new QuotationDM(_GlobalErrors) { ID = item.QuotationID }; QuotDetailsDM.Category = new CategoryDM(_GlobalErrors) { ID = item.CategoryID, CategoryName = item.Category.CategoryName }; QuotaionDetailsDMList.Add(QuotDetailsDM); } } return(QuotaionDetailsDMList); }
public void AddDetails(QuotaionDetailsDM domain) { try { if (domain == null) { return; } QuotationDetail obj = new QuotationDetail(); obj.NumberOfDays = domain.NumberOfDays; obj.CategoryID = domain.Category.ID; obj.Price = domain.Price; obj.QuotationID = domain.Quotaion.ID; _DbContext.QuotationDetails.Add(obj); _DbContext.SaveChanges(); } catch (Exception ex) { //Errors in this scope indicates system error (not validation errors) //If error not handled, log it and add system error if (!_GlobalErrors.ErrorHandled) { _Logger.Error(ex, "Database Error: Cannot Add QuotationDetails!"); _GlobalErrors.AddSystemError("Database Error: Cannot Add QuotationDetails!"); _GlobalErrors.ErrorHandled = true; } throw; } }
public QuotaionDetailsVM(QuotaionDetailsDM QuotaionDetails) { ID = QuotaionDetails.ID; JobID = QuotaionDetails.Quotaion.ID; CategoryID = QuotaionDetails.Category.ID; CategoryName = QuotaionDetails.Category.CategoryName; //StartDate = QuotaionDetails.StartDate; //EndDate = QuotaionDetails.EndDate; Price = QuotaionDetails.Price; NumberOfDays = QuotaionDetails.NumberOfDays; }
public QuotaionDetailsDM MapVM_DM() { GlobalErrors globalErrors = new GlobalErrors(); QuotaionDetailsDM obj = new QuotaionDetailsDM(globalErrors); obj.ID = ID; obj.Quotaion = new QuotationDM(globalErrors) { ID = JobID }; obj.Category = new CategoryDM(globalErrors) { ID = CategoryID }; //obj.StartDate = StartDate; //obj.EndDate = EndDate; obj.Price = Price; obj.NumberOfDays = NumberOfDays; return(obj); }
public QuotationDM GetQuotationForCategory(QuotationDM domainModel) { try { if (domainModel.FromLangID == domainModel.ToLangID) { _GlobalErrors.AddValidationError("", "From language equla Tatrget language"); _GlobalErrors.ErrorHandled = true; throw new Exception(); } CategoryService _CategorySer = new CategoryService(_GlobalErrors); domainModel.StartDate = DateTime.Now; _QuotaionRepo.Add(domainModel); if (domainModel.CategoryID == null) { domainModel.CategoryDMList = _CategorySer.GetAllCategories(); domainModel.QuotaionDetailsList = new List<QuotaionDetailsDM>(); foreach (var item in domainModel.CategoryDMList) { QuotaionDetailsDM obj = new QuotaionDetailsDM(_GlobalErrors); obj.Category = item; obj.Quotaion = domainModel; obj.AddCalculatedQuotation(); _QuotaionRepo.AddDetails(obj); domainModel.QuotaionDetailsList.Add(obj); } } else { CategoryDM CatObj = _CategorySer.GetById(domainModel.CategoryID); domainModel.QuotaionDetailsList = new List<QuotaionDetailsDM>(); QuotaionDetailsDM obj = new QuotaionDetailsDM(_GlobalErrors); obj.Category = CatObj; obj.Quotaion = domainModel; obj.AddCalculatedQuotation(); _QuotaionRepo.AddDetails(obj); domainModel.QuotaionDetailsList.Add(obj); } return domainModel; } catch (Exception ex) { //Errors in this scope indicates system error (not validation errors) //If error exist but not handled, log it and add system error if (!_GlobalErrors.ErrorHandled) { _Logger.Error(ex, "Service Error: Cannot Request Quotation!"); _GlobalErrors.AddSystemError("Service Error: Cannot Request Quotation!"); _GlobalErrors.ErrorHandled = true; } throw; } }