//get the asset's spec by the machine's serial number public List <Models.magentoViewModel> get_spec(int asset_tag) { string result = (from b in db.rediscovery where b.ictag == asset_tag select b.serial).SingleOrDefault(); var spec = (from t in db.production_log where t.serial == result from h in db.rediscovery where t.serial == h.serial select new Models.magentoViewModel { hdd = t.HDD, cpu = t.CPU, brand = t.Manufacture, ram = t.RAM, ictags = asset_tag, model = t.Model, serial = h.serial, screen_size = t.screen_size, video_card = t.video_card, optical = h.optical_drive, pallet_name = h.pallet }).ToList(); if (spec.Count() == 0) { spec = rediscovery(asset_tag); return(spec); } var temp_cpu = spec[0].cpu; var temp_hdd = spec[0].hdd; if (temp_hdd.Contains("GB")) { temp_hdd = temp_hdd.Replace("GB", ""); } int formatted_hdd = int.Parse(temp_hdd); formatted_hdd = Convert.ToInt32(formatted_hdd * 1.024 * 1.024); formatted_hdd = Levenshtein.Round(formatted_hdd, 10); switch (formatted_hdd) { case 480: formatted_hdd = 500; temp_hdd = formatted_hdd + "GB HDD"; break; case 980: formatted_hdd = 1000; temp_hdd = formatted_hdd / 1000 + "TB HDD"; break; default: temp_hdd = formatted_hdd + "GB HDD"; break; } string formatted_cpu = Levenshtein.comput_title(temp_cpu); spec[0].cpu = formatted_cpu; spec[0].hdd = temp_hdd; return(spec); }
public List <Models.magentoViewModel> rediscovery(int asset_tag) { var result = (from t in db.rediscovery where t.ictag == asset_tag select new Models.magentoViewModel { hdd = t.hdd, cpu = t.cpu, brand = t.brand, ram = t.ram, ictags = asset_tag, model = t.model, serial = t.serial, screen_size = "NA", video_card = "NA", optical = t.optical_drive, pallet_name = t.pallet }).ToList(); var temp_cpu = result[0].cpu; var temp_hdd = result[0].hdd; if (temp_hdd.Contains("GB")) { temp_hdd = temp_hdd.Replace("GB", ""); } if (temp_hdd.Contains("SSD")) { temp_hdd = temp_hdd.Replace("SSD", ""); } int formatted_hdd = int.Parse(temp_hdd); formatted_hdd = Convert.ToInt32(formatted_hdd * 1.024 * 1.024); formatted_hdd = Levenshtein.Round(formatted_hdd, 10); switch (formatted_hdd) { case 480: formatted_hdd = 500; temp_hdd = formatted_hdd + "GB HDD"; break; case 980: formatted_hdd = 1000; temp_hdd = formatted_hdd / 1000 + "TB HDD"; break; default: temp_hdd = formatted_hdd + "GB HDD"; break; } string formatted_cpu = Levenshtein.comput_title(temp_cpu); result[0].cpu = formatted_cpu; result[0].hdd = temp_hdd; return(result); }