public ActionResult LoadSuppliers() { RatingsViewModel RatingModel = (RatingsViewModel)TempData["SearchedResults"]; TempData.Keep("SearchedResults"); if (RatingModel != null) { var rateSuppliers = RatingModel.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); //var modifiedlist = selectSuppliers.Select(r => new SelectListItem { Text = r.Text + " CID:" + r.Value, Value = r.Value }).ToList(); var modifiedlist = selectSupplierscid; var NotinListSuppliers = (from fulllist in modifiedlist where !(rateSuppliers.Any(i => i.Value == fulllist.Value)) select fulllist).ToList(); if (NotinListSuppliers != null) { ViewBag.Suppliers = NotinListSuppliers; } else { ViewBag.Suppliers = modifiedlist; } } else { var modifiedlist = selectSupplierscid; ViewBag.Suppliers = modifiedlist; } return(PartialView("_AddSupplier")); }
public ActionResult AddRowReload(int CID) { //RatingsViewModel RatingModel = new RatingsViewModel(); RatingsViewModel RatingModel = (RatingsViewModel)TempData["SearchedResults"]; RatingRecord NewRec = GetSupplierDataByCID(CID, RatingModel.SiteID.Value); RatingModel.RatingRecords.Add(NewRec); TempData["SearchedResults"] = RatingModel; //List<RatingRecord> Records = new List<RatingRecord>(); //ViewBag.newIndex = count; //for(int i =0;i<count; i++) //{ // RatingRecord empRec = new RatingRecord(); // empRec.CID = 0; // Records.Add(empRec); //} //Records.Add(NewRec); //RatingModel.RatingRecords = Records; //return PartialView("_AppendRow", RatingModel); var rateSuppliers = RatingModel.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); ViewBag.RatingSuppliers = rateSuppliers; return(PartialView("_SupplierRatings", RatingModel)); }
public ActionResult UploadIndex(ExcelRatingsViewModel RatingModel) { RatingsViewModel rating = new RatingsViewModel(); rating = Merge(RatingModel); TempData["SearchedResults"] = rating; var rateSuppliers = rating.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); var modifiedlist = selectSuppliers.Select(r => new SelectListItem { Text = r.Text + " CID:" + r.Value, Value = r.Value }).ToList(); ViewBag.RatingSuppliers = rateSuppliers; var NotinListSuppliers = (from fulllist in modifiedlist where !(rateSuppliers.Any(i => i.Value == fulllist.Value)) select fulllist).ToList(); if (NotinListSuppliers != null) { ViewBag.Suppliers = NotinListSuppliers; } else { ViewBag.Suppliers = modifiedlist; } // ViewBag.Suppliers = modifiedlist; return(View("UploadIndex", rating)); }
public List <RatingRecord> IncidentSpendOrder(RatingsViewModel RatingModel) { List <RatingRecord> recordsChild = new List <RatingRecord>(); List <RatingRecord> recordsParent = new List <RatingRecord>(); List <RatingRecord> Mergedrecords = new List <RatingRecord>(); List <RatingRecord> Sortedrecords = new List <RatingRecord>(); using (Repository Rep = new Repository()) { recordsChild = (from site in Rep.Context.SPFS_SITES join spend in Rep.Context.SPFS_SPEND_SUPPLIERS on site.SiteID equals spend.SiteID join sup in Rep.Context.SPFS_SUPPLIERS on spend.CID equals sup.CID where spend.SiteID == RatingModel.SiteID select new RatingRecord { CID = spend.CID, SiteID = spend.SiteID, Gdis_org_entity_ID = site.Gdis_org_entity_ID, Gdis_org_Parent_ID = site.Gdis_org_Parent_ID, Reject_incident_count = spend.Reject_incident_count, Reject_parts_count = spend.Reject_parts_count, SupplierName = sup.Name, DUNS = sup.Duns }).ToList(); var parentID = recordsChild.Max(p => p.Gdis_org_Parent_ID); recordsParent = (from spend in Rep.Context.SPFS_SPEND_SUPPLIERS where spend.Gdis_org_Parent_ID == parentID group spend by new { spend.CID, spend.Gdis_org_Parent_ID } into g select new RatingRecord { CID = g.Key.CID, Gdis_org_Parent_ID = g.Key.Gdis_org_Parent_ID, Total_Spend = g.Sum(x => x.Total_Spend) }).ToList(); } Mergedrecords = (from child in recordsChild join parent in recordsParent on new { child.CID, child.Gdis_org_Parent_ID } equals new { parent.CID, parent.Gdis_org_Parent_ID } into merged from m in merged.DefaultIfEmpty() select new RatingRecord { CID = child.CID, DUNS = child.DUNS, SiteID = child.SiteID, Gdis_org_entity_ID = child.Gdis_org_entity_ID, Gdis_org_Parent_ID = child.Gdis_org_Parent_ID, Reject_incident_count = child.Reject_incident_count, Reject_parts_count = child.Reject_parts_count, Total_Spend = m == null ? 0 : m.Total_Spend, SupplierName = child.SupplierName }).ToList(); Sortedrecords = Mergedrecords.OrderByDescending(x => x.Reject_incident_count).ThenByDescending(x => x.Total_Spend).ToList(); return(Sortedrecords); }
public ActionResult SaveRating(int id, Rating rating) { if (!ModelState.IsValid) { var book = _context.Books.SingleOrDefault(b => b.Id == id); var viewModel = new RatingsViewModel { Rating = new Rating(), Book = book }; return(View("Ratings", viewModel)); } if (rating.Id == 0) { _context.Ratings.Add(rating); } try { _context.SaveChanges(); } catch (DbEntityValidationException e) { Console.WriteLine(e); } return(RedirectToAction("Index", "Books")); }
public ActionResult Ratings(int id) { var book = _context.Books.SingleOrDefault(b => b.Id == id); var viewModel = new RatingsViewModel { Rating = new Rating(), Book = book }; return(View("Ratings", viewModel)); }
public RatingsViewModel ViewListVotes(string userId) { RatingsViewModel vm = new RatingsViewModel(); vm.Value1 = db.Ratings.Where(x => x.Value == 1 && x.UserId == userId).Count(); vm.Value2 = db.Ratings.Where(x => x.Value == 2 && x.UserId == userId).Count(); vm.Value3 = db.Ratings.Where(x => x.Value == 3 && x.UserId == userId).Count(); vm.Value4 = db.Ratings.Where(x => x.Value == 4 && x.UserId == userId).Count(); vm.Value5 = db.Ratings.Where(x => x.Value == 5 && x.UserId == userId).Count(); return(vm); }
public ActionResult SaveData(RatingsViewModel ratingModel) { if (true) { ModelState.AddModelError("", "error"); } if (ModelState.IsValid) { } return(View("UploadIndex", ratingModel)); }
public ActionResult Ratings() { var userId = User.Identity.GetUserId(); var ratings = _unitOfWork.Ratings.GetUserRatings(userId); var viewModel = new RatingsViewModel { RatingsToDisplay = ratings, ShowActions = true, Heading = "My Ratings" }; return(View("Ratings", viewModel)); }
private static List <RatingRecord> ProdRecords(RatingsViewModel ratingModel, int CheckingDate, Repository Rep) { return((from ratings in Rep.Context.SPFS_SUPPLIER_RATINGS where ratings.SiteID == ratingModel.SiteID && ratings.Rating_period == CheckingDate select new RatingRecord { CID = ratings.CID, SiteID = ratings.SiteID, Inbound_parts = ratings.Inbound_parts, OTR = ratings.OTR, OTD = ratings.OTD, PFR = ratings.PFR }).ToList()); }
public ActionResult MyInteractions() { var UserId = System.Web.HttpContext.Current.User.Identity.GetUserId(); MyInteractionsViewModel myInteractions = new MyInteractionsViewModel(); myInteractions.Interactions = new List <InteractionViewModel>(); UserToActivityViewModel userToActivity = new UserToActivityViewModel(); userToActivity.UserToActivities = new List <UserToActivityModel>(); foreach (var row in db.UserToActivity.Include(n => n.User)) { userToActivity.UserToActivities.Add(row); } RatingsViewModel ratings = new RatingsViewModel(); ratings.Ratings = new List <RatingModel>(); foreach (var rating in db.Rating) { ratings.Ratings.Add(rating); } //Selects all activities the user has taken part in. foreach (var row in db.UserToActivity.Include(n => n.Activity).Where(n => n.UserId == UserId).Where(n => n.Activity.TimeEnd < DateTime.Now)) { //selects all other participants in those same activities foreach (var person in userToActivity.UserToActivities.Where(n => n.ActivityId == row.ActivityId).Where(n => n.UserId != null)) { //do not include users previously reviewd by this user InteractionViewModel interaction = new InteractionViewModel { Activity = row.Activity }; interaction.User = person.User; if (interaction.User.Id != UserId) { myInteractions.Interactions.Add(interaction); } foreach (var rating in ratings.Ratings.Where(n => n.UserId == person.UserId)) { if (rating.ReviewerId == UserId) { myInteractions.Interactions.Remove(interaction); } } } } return(View(myInteractions)); }
//public ActionResult LoadAlertData(RatingsViewModel RatingModel, bool isStaging ,bool isLastmonth) public ActionResult LoadAlertData(int SiteID, int Year, int Month, bool isStaging, bool isLastmonth) { RatingsViewModel RatingModel = new RatingsViewModel() { SiteID = SiteID, Year = Year, Month = Month }; using (Repository Rep = new Repository()) { int CheckingDate; if (isStaging) { if (isLastmonth) { CheckingDate = Convert.ToInt32("" + RatingModel.Year + (RatingModel.Month - 1).ToString().PadLeft(2, '0')); } else { CheckingDate = Convert.ToInt32("" + RatingModel.Year + (RatingModel.Month).ToString().PadLeft(2, '0')); } RatingModel.RatingRecords = StageRecords(RatingModel, CheckingDate, Rep); } else { CheckingDate = Convert.ToInt32("" + RatingModel.Year + (RatingModel.Month).ToString().PadLeft(2, '0')); RatingModel.RatingRecords = ProdRecords(RatingModel, CheckingDate, Rep); } } CreateListViewBags(); // ViewBag.Suppliers = selectSuppliers; ratingModel.RatingRecords = IncidentSpendOrder(ratingModel); RatingsViewModel UpdatedModel = Merge(RatingModel); var rateSuppliers = UpdatedModel.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); LoadDropdowns(rateSuppliers); UpdatedModel.ShowResult = true; UpdatedModel.OldResults = false; UpdatedModel.EditMode = true; TempData["SearchedResults"] = UpdatedModel; return(View("Index", UpdatedModel)); }
// GET: Ratings public ActionResult Index(int?SiteID, bool isUpload = false) { RatingsViewModel ratingsViewModel = new RatingsViewModel { SiteID = SiteID, isUpload = isUpload, RatingRecords = new List <RatingRecord>() }; ratingsViewModel.Month = DateTime.Now.Month - 1; ratingsViewModel.Year = DateTime.Now.Year; CreateListViewBags(); ViewBag.Suppliers = selectSuppliers.Select(r => new SelectListItem { Text = r.Text + " CID:" + r.Value, Value = r.Value }).ToList(); ratingsViewModel.ShowResult = false; ratingsViewModel.OldResults = false; ratingsViewModel.EditMode = true; return(View(ratingsViewModel)); }
public JsonResult UpdateRating(int CID, int Inbound, int OTR, int OTD, int PFR, double PPM, double IPM, double PCT) { //RatingsViewModel RatingModel = new RatingsViewModel(); RatingsViewModel RatingModel = (RatingsViewModel)TempData["SearchedResults"]; RatingRecord Rec = RatingModel.RatingRecords.Where(r => r.CID.Equals(CID)).Select(r => { r.Inbound_parts = Inbound; r.IPM = IPM; r.OTD = OTD; r.OTR = OTR; r.PCT = PCT; r.PFR = PFR; r.PPM = PPM; return(r); }).FirstOrDefault(); TempData["SearchedResults"] = RatingModel; return(Json(true, JsonRequestBehavior.AllowGet)); }
public JsonResult GetSupplierbyName(string nameString, bool?errorCheck) { if (!errorCheck.HasValue) { RatingsViewModel RatingModel = (RatingsViewModel)TempData["SearchedResults"]; TempData.Keep("SearchedResults"); List <SelectListItem> SupplierList; if (RatingModel != null) { var rateSuppliers = RatingModel.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); var modifiedlist = selectSupplierscid; var NotinListSuppliers = (from fulllist in modifiedlist where !(rateSuppliers.Any(i => i.Value == fulllist.Value)) select fulllist).ToList(); if (NotinListSuppliers != null) { SupplierList = NotinListSuppliers; } else { SupplierList = modifiedlist; } } else { var modifiedlist = selectSupplierscid; SupplierList = modifiedlist; } var newSuppliercache = string.IsNullOrWhiteSpace(nameString) ? SupplierList : SupplierList.Where(s => s.Text.StartsWith(nameString, StringComparison.InvariantCultureIgnoreCase)); return(Json(newSuppliercache, JsonRequestBehavior.AllowGet)); } else { var newSuppliercache = string.IsNullOrWhiteSpace(nameString) ? selectSupplierscid : selectSupplierscid.Where(s => s.Text.StartsWith(nameString, StringComparison.InvariantCultureIgnoreCase)); return(Json(newSuppliercache, JsonRequestBehavior.AllowGet)); } }
public RatingsViewModel GetRatings(int vehicleId) { RatingsViewModel model = new RatingsViewModel() { ratings = _context.Ratings.Include(x => x.User).Where(x => x.VehicleId == vehicleId).Select(x => new RatingsViewModel.Ratings { Comment = x.Comment, DateReviewed = x.DateReviewed.ToString("dd-MM-yyyy"), User = new Model.UserViewModel { FirstName = x.User.FirstName, LastName = x.User.LastName, Username = x.User.Username }, RatingMark = x.RatingMark }).OrderByDescending(x => x.DateReviewed).ToList() }; return(model); }
private ActionResult LoadData(RatingsViewModel ratingModel, bool dataExists) { CreateListViewBags(); RatingsViewModel UpdatedModel = new RatingsViewModel(); // ViewBag.Suppliers = selectSuppliers; ratingModel.RatingRecords = IncidentSpendOrder(ratingModel); if (dataExists) { UpdatedModel = Merge(ratingModel); var rateSuppliers = UpdatedModel.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); LoadDropdowns(rateSuppliers); } else { UpdatedModel.RatingRecords = IncidentSpendOrder(ratingModel); UpdatedModel.isUpload = false; UpdatedModel.Month = ratingModel.Month; UpdatedModel.Year = ratingModel.Year; UpdatedModel.SiteID = ratingModel.SiteID; SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(ratingModel.SiteID)).FirstOrDefault(); UpdatedModel.SiteName = gdis.Name; var rateSuppliers = ratingModel.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); LoadDropdowns(rateSuppliers); } UpdatedModel.ShowResult = true; UpdatedModel.OldResults = false; UpdatedModel.EditMode = true; TempData["SearchedResults"] = UpdatedModel; return(View("Index", UpdatedModel)); }
public MovieViewModel GetMoviesByMovieID(int mid, int uid) { Movies m = mr.GetMoviesByMovieID(mid).FirstOrDefault(); MovieViewModel mvm = null; if (m != null) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <Movies, MovieViewModel>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); mvm = mapper.Map <Movies, MovieViewModel>(m); foreach (var item in mvm.Reviews) { item.CurrentUserRatingType = 0; RatingsViewModel vote = item.Ratings.Where(temp => temp.UserID == uid).FirstOrDefault(); if (vote != null) { item.CurrentUserRatingType = vote.RatingValue; } } } return(mvm); }
private RatingsViewModel Merge(ExcelRatingsViewModel RatingModel) { List <RatingRecord> Records = (List <RatingRecord>)TempData["RatingRecords"]; //TempData.Keep("RatingRecords"); ExcelRatingsViewModel AggregatedModel = AggregateRecords(RatingModel, Records); RatingsViewModel ConvertedModel = new RatingsViewModel(); List <RatingRecord> ISORecords = IncidentSpendOrder(RatingModel); //List<RatingRecord> HistoryRecords = IncidentSpendOrder(RatingModel); List <RatingRecord> MergedRecords = new List <RatingRecord>(); List <RatingRecord> UnMatchedRecords = new List <RatingRecord>(); var query = from x in ISORecords join y in AggregatedModel.RatingRecords on x.CID equals y.CID select new { x, y }; foreach (var match in query) { match.x.Inbound_parts = match.y.Inbound_parts; match.x.OTD = match.y.OTD; match.x.OTR = match.y.OTR; match.x.PFR = match.y.PFR; match.x.Reject_incident_count = match.y.Reject_incident_count; match.x.Reject_parts_count = match.y.Reject_parts_count; match.x.Temp_Upload_ = match.y.Temp_Upload_; match.x.ErrorInformation = match.y.ErrorInformation; } // MergedRecords = ISORecords; var unmatch = (from agrr in AggregatedModel.RatingRecords where !(ISORecords.Any(i => i.CID == agrr.CID)) select agrr).ToList(); if (unmatch != null) { ISORecords.AddRange(unmatch); } MergedRecords = ISORecords; foreach (RatingRecord rec in MergedRecords) { if (rec.Inbound_parts != 0) { double ppm = (double)rec.Reject_parts_count / rec.Inbound_parts; rec.PPM = Math.Round(ppm * 1000000); double ipm = (double)rec.Reject_incident_count / rec.Inbound_parts; rec.IPM = Math.Round((ipm * 1000000), 2); } else { rec.PPM = 0; rec.IPM = 0.00; } if (rec.OTD != 0) { double pct = (double)rec.OTR / rec.OTD; rec.PCT = Math.Round(pct * 100); } else { rec.PCT = 0; } } ConvertedModel.RatingRecords = MergedRecords; ConvertedModel.isUpload = true; ConvertedModel.Month = RatingModel.Month; ConvertedModel.Year = RatingModel.Year; ConvertedModel.SiteID = RatingModel.SiteID; SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(RatingModel.SiteID)).FirstOrDefault(); ConvertedModel.SiteName = gdis.Name; //var count = 0; //foreach (var record in GroupedRecords) //{ // if ((record.ErrorInformation != null ? record.ErrorInformation.Count : 0) > 0) // { // count++; // } //} return(ConvertedModel); }
public ActionResult Search(RatingsViewModel ratingModel) { RatingsViewModel excelViewModel = new RatingsViewModel(); var historicalRecords = new List <HistoricalRecordsCheck>(); DateTime date = new DateTime(ratingModel.Year, ratingModel.Month, 01); DateTime current = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 01); // ratingModel.Month = Convert.ToInt32(ratingModel.Month.ToString().PadLeft(2, '0')); if (current.AddMonths(-4) < date) { int CheckingDate = Convert.ToInt32("" + ratingModel.Year + ratingModel.Month.ToString().PadLeft(2, '0')); List <RatingRecord> StagingRecords = new List <RatingRecord>(); List <RatingRecord> CurrentRecords = new List <RatingRecord>(); List <RatingRecord> PreviousMonthRecords = new List <RatingRecord>(); List <RatingRecord> PreviousMonthRecordsStaging = new List <RatingRecord>(); Utilities util = new Utilities(); using (Repository Rep = new Repository()) { CurrentRecords = ProdRecords(ratingModel, CheckingDate, Rep); int CurrentCount = CurrentRecords != null ? CurrentRecords.Count : 0; if (CurrentCount <= 0) { StagingRecords = StageRecords(ratingModel, CheckingDate, Rep); if (StagingRecords.Count > 0) { ratingModel.IsStagingRatings = true; ratingModel.RatingRecords = StagingRecords; ViewBag.divmsg = "Data exists for this rating period that has <strong>Not</strong> been <strong>Submitted</strong>"; //There are existing records submitted for this month //display data from staging return(LoadData(ratingModel, ratingModel.IsStagingRatings)); } else { if (current.AddMonths(-1) <= date) { int CheckingDate_Previous = Convert.ToInt32("" + date.Year + (date.Month - 1).ToString().PadLeft(2, '0')); PreviousMonthRecords = ProdRecords(ratingModel, CheckingDate_Previous, Rep); if (PreviousMonthRecords.Count > 0) { //display current months grid ratingModel.IsPreviousRatings = true; ratingModel.RatingRecords = CurrentRecords; ViewBag.divmsg = "Last month data check was succesfull"; return(LoadData(ratingModel, false)); } else { PreviousMonthRecordsStaging = StageRecords(ratingModel, CheckingDate_Previous, Rep); if (PreviousMonthRecordsStaging.Count > 0) { //you havent submitted last months data. would you like to finish //Yes - Load last months data //No - Continue with current ratings ratingModel.IsAlert = true; ratingModel.IsPreviousStagingRatings = true; ViewBag.alertmsg = "Data exists for last ratings period which has <strong>Not</strong> been <strong>Submitted!</strong>"; ratingModel.ShowResult = false; ratingModel.EditMode = false; CreateListViewBags(); return(View("Index", ratingModel)); } else { //display current months grid ratingModel.RatingRecords = CurrentRecords; ViewBag.divmsg = "This is not current period"; return(LoadData(ratingModel, false)); } } } else { //display grid ratingModel.RatingRecords = CurrentRecords; ViewBag.divmsg = "This is not current period"; return(LoadData(ratingModel, false)); } } } else { //data exists for you and any changes will overwrite existing data. Press clear to stop editing submittedratings ratingModel.IsAlert = true; ratingModel.IsCurrentRatings = true; ViewBag.alertmsg = "Data exists and has been <strong>Submitted</strong> for this rating period. Do you wish to <strong>Edit</strong> these previously <strong>Submitted</strong> ratings?"; ratingModel.ShowResult = false; ratingModel.EditMode = false; CreateListViewBags(); return(View("Index", ratingModel)); } } } else { int CheckingDate = Convert.ToInt32("" + ratingModel.Year + ratingModel.Month.ToString().PadLeft(2, '0')); List <RatingRecord> OldRecords = new List <RatingRecord>(); using (Repository Rep = new Repository()) { OldRecords = ProdRecords(ratingModel, CheckingDate, Rep); } if (OldRecords.Count > 0) { List <RatingRecord> OldRecordsUpdated = new List <RatingRecord>(); foreach (RatingRecord rec in OldRecords) { rec.DUNS = GetDUNSfromCID(rec.CID); rec.SupplierName = selectSuppliers.Where(r => r.Value == rec.CID.ToString()).First().Text; OldRecordsUpdated.Add(rec); } ratingModel.RatingRecords = OldRecordsUpdated; CreateListViewBags(); // ViewBag.Suppliers = selectSuppliers; RatingsViewModel UpdatedModel = Merge(ratingModel); var rateSuppliers = UpdatedModel.RatingRecords.Select(r => new SelectListItem { Text = r.SupplierName + " CID:" + r.CID, Value = r.CID.ToString() }).ToList(); var modifiedlist = selectSuppliers.Select(r => new SelectListItem { Text = r.Text + " CID:" + r.Value, Value = r.Value }).ToList(); ViewBag.RatingSuppliers = rateSuppliers; ratingModel.ShowResult = true; ratingModel.OldResults = true; ratingModel.EditMode = false; return(View("Index", UpdatedModel)); } else { ratingModel.ShowResult = false; ratingModel.EditMode = false; CreateListViewBags(); return(View("Index", ratingModel)); } } }
public RatingsPage() { InitializeComponent(); BindingContext = new RatingsViewModel(); }
public ActionResult SubmitData(RatingsViewModel ratingModel) { return(View("Index", ratingModel)); }
private RatingsViewModel Merge(RatingsViewModel RatingModel) { RatingsViewModel RateModel = new RatingsViewModel(); List <RatingRecord> ISORecords = IncidentSpendOrder(RatingModel); List <RatingRecord> MergedRecords = new List <RatingRecord>(); //List<RatingRecord> UnMatchedRecords = new List<RatingRecord>(); var query = from x in ISORecords join y in RatingModel.RatingRecords on x.CID equals y.CID select new { x, y }; foreach (var match in query) { match.x.Inbound_parts = match.y.Inbound_parts; match.x.OTD = match.y.OTD; match.x.OTR = match.y.OTR; match.x.PFR = match.y.PFR; match.x.Temp_Upload_ = match.y.Temp_Upload_; match.x.ErrorInformation = match.y.ErrorInformation; } // MergedRecords = ISORecords; //var unmatch = (from agrr in RatingModel.RatingRecords // where !(ISORecords.Any(i => i.CID == agrr.CID)) // select agrr).ToList(); //if (unmatch != null) //{ // ISORecords.AddRange(unmatch); //} MergedRecords = ISORecords; foreach (RatingRecord rec in MergedRecords) { if (rec.Inbound_parts != 0) { double ppm = (double)rec.Reject_parts_count / rec.Inbound_parts; rec.PPM = Math.Round(ppm * 1000000); double ipm = (double)rec.Reject_incident_count / rec.Inbound_parts; rec.IPM = Math.Round((ipm * 1000000), 2); } else { rec.PPM = 0; rec.IPM = 0.00; } if (rec.OTD != 0) { double pct = (double)rec.OTR / rec.OTD; rec.PCT = Math.Round(pct * 100); } else { rec.PCT = 0; } } RateModel.RatingRecords = MergedRecords; RateModel.isUpload = false; RateModel.Month = RatingModel.Month; RateModel.Year = RatingModel.Year; RateModel.SiteID = RatingModel.SiteID; SelectSiteGDIS gdis = selectGDIS.Where(g => g.SiteID.Equals(RatingModel.SiteID)).FirstOrDefault(); RateModel.SiteName = gdis.Name; return(RateModel); }