// GET: CallScreen public ActionResult Index(string reference) { Phone_SystemEntities10 db = new Phone_SystemEntities10(); DailyCall model = new DailyCall(); model = db.DailyCalls.Where(x => x.ClientReference == reference).FirstOrDefault(); model.Outcomes = new SelectList(db.CallOutcomeLists.ToList(), "OutcomeID", "Name"); return(View(model)); }
public ActionResult Index(DailyCall model) { Phone_SystemEntities10 db = new Phone_SystemEntities10(); int id = model.ID; //make sure reference is unique //if(db.CallOutcomes.Any(x=>x.Reference == model.Reference)) //{ //} db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(Redirect("~/Home/Index")); }
public ActionResult Upload(DailyCall objEmpDetail, HttpPostedFileBase FileUpload) { Phone_SystemEntities10 objEntity = new Phone_SystemEntities10(); string data = ""; if (FileUpload != null) { if (FileUpload.ContentType == "application/vnd.ms-excel" || FileUpload.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { string filename = FileUpload.FileName; if (filename.EndsWith(".xlsx")) { string targetpath = Server.MapPath("~/"); FileUpload.SaveAs(targetpath + filename); string pathToExcelFile = targetpath + filename; string sheetName = "Sheet1"; var excelFile = new ExcelQueryFactory(pathToExcelFile); var empDetails = from a in excelFile.Worksheet <DailyCall>(sheetName) select a; foreach (var a in empDetails) { if (a.Name != null) { int result = PostExcelData(a.Name, a.ClientReference, a.TelephoneNumber, a.Date, a.OutcomeId, a.LastCalled); if (result <= 0) { data = "Hello User, Found some duplicate values!"; ViewBag.Message = data; continue; } else { data = "Successfully uploaded spreadsheet"; ViewBag.Message = data; } } else { data = a.Name + "Some fields are null, Please check your excel sheet"; ViewBag.Message = data; return(View("Upload")); } } } else { data = "This file is not in a valid format"; ViewBag.Message = data; } return(View("Upload")); } else { data = "Only Excel file format is allowed"; ViewBag.Message = data; return(View("ExcelUpload")); } } else { if (FileUpload == null) { data = "Please choose Excel file"; } ViewBag.Message = data; return(View("Upload")); } }