public async Task <ActionResult> CatererLogin(Caterer user) { using (var db = new AppDbContext()) { Caterer usr = db.Caterers.Where(u => (u.Email == user.Email && u.Password == user.Password)).FirstOrDefault(); if (usr != null) { Session["CatererEmail"] = usr.Email; Session["CatererId"] = usr.Id; ViewBag.Email = usr.Email; ViewBag.CatererId = usr.Id; return(RedirectToAction("CatererIndex", "Home")); } else { ViewBag.ErrorMsg = "Login failed!"; Session["CatererEmail"] = null; Session["CatererId"] = null; ViewBag.Email = string.Empty; ViewBag.CatererId = "-1"; } } return(View()); }
public IHttpActionResult PutCaterer(int id, Caterer caterer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != caterer.Id) { return(BadRequest()); } db.Entry(caterer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CatererExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Post([FromBody] Caterer entity) { if (ModelState.IsValid) { repository.Add(entity); } }
public int Post(Caterer entity) { if (ModelState.IsValid) { return(_repository.Adding(entity)); } return(0); }
public void Put(int id, [FromBody] Caterer entity) { entity.IDCaterer = id; if (ModelState.IsValid) { repository.Update(entity); } }
public Caterer CreateCaterer(Caterer caterer) { caterer.User.IsActive = true; caterer.User.IsDeleted = false; caterer.Brand.IsActive = true; return(_opfcUow.BrandRepository.CreateCaterer(caterer.User, caterer.Brand)); }
public IActionResult Edit(Caterer obj) { if (ModelState.IsValid) { _db.Caterers.Update(obj); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(obj)); }
public ActionResult CaterersBySP() { Caterer Deco = CRUD.getAllCaterersBySP(Session["SP_username"].ToString()); if (Deco == null) { RedirectToAction("MainPage"); } Console.Write(Deco); return(View(Deco)); }
public IHttpActionResult GetCaterer(int id) { Caterer caterer = db.Caterers.Find(id); if (caterer == null) { return(NotFound()); } return(Ok(caterer)); }
public IHttpActionResult PostCaterer(Caterer caterer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Caterers.Add(caterer); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = caterer.Id }, caterer)); }
public IHttpActionResult DeleteCaterer(int id) { Caterer caterer = db.Caterers.Find(id); if (caterer == null) { return(NotFound()); } db.Caterers.Remove(caterer); db.SaveChanges(); return(Ok(caterer)); }
public async Task Update(Caterer caterer) { if (!ExecuteValidation(new CatererValidation(), caterer)) { return; } if (_repoCaterer.Search(c => c.Document == caterer.Document && c.Id != caterer.Id).Result.Any()) { Notify("A caterer with this document already exists."); return; } await _repoCaterer.Update(caterer); }
public async Task Add(Caterer caterer) { if (!ExecuteValidation(new CatererValidation(), caterer) || !ExecuteValidation(new AddressValidation(), caterer.Address)) { return; } if (_repoCaterer.Search(c => c.Document == caterer.Document).Result.Any()) { Notify("A caterer with this document already exists."); return; } await _repoCaterer.Add(caterer); }
public async Task <ActionResult> CatererRegister(Caterer user) { ViewBag.ErrMsg = string.Empty; ViewBag.SuccessMsg = string.Empty; using (var db = new AppDbContext()) { Caterer c = db.Caterers.Where(u => u.Email == user.Email).FirstOrDefault(); if (c != null) { ViewBag.ErrMsg = "Caterer Exists!"; } else { db.Caterers.Add(user); db.SaveChanges(); ViewBag.SuccessMsg = "Caterer Added!"; } } return(View()); }
public List <Item> Get(Caterer model) { return(Utilities.CreateItem(model));; }
//public static Tuple<List<string>, List<string>> ReturnMultipleList(int[] array, int number) //{ // return Tuple.Create(list1, list2); //} public static List <Item> CreateItem(Caterer model) { _tempList = new List <Item>(); _temp = new Item(); string json = null; var stream2 = new MemoryStream(model.Document); IFormFile file = new FormFile(stream2, 0, model.Document.Length, "name", "filename.xlsx"); string folderName = "UploadExcel"; string sFileExtension = Path.GetExtension(file.FileName).ToLower(); List <string> ItemLista = new List <string>(); List <string> IngredientsLista = new List <string>(); if (file.Length > 0) { ISheet sheet; using (var stream = file.OpenReadStream()) { //json = ReadExcelasJSON(stream); stream.Position = 0; if (sFileExtension == ".xls") { HSSFWorkbook hssfwb = new HSSFWorkbook(stream); //This will read the Excel 97-2000 formats sheet = hssfwb.GetSheetAt(0); //get first sheet from workbook } else { XSSFWorkbook hssfwb = new XSSFWorkbook(stream); //This will read 2007 Excel format sheet = hssfwb.GetSheetAt(0); //get first sheet from workbook } IRow headerRow = sheet.GetRow(0); //Get Header Row int cellCount = headerRow.LastCellNum; for (int j = 0; j < cellCount; j++) { NPOI.SS.UserModel.ICell cell = headerRow.GetCell(j); if (cell == null || string.IsNullOrWhiteSpace(cell.ToString())) { continue; } } for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++) //Read Excel File { IRow row = sheet.GetRow(i); if (row == null) { continue; } if (row.Cells.All(d => d.CellType == NPOI.SS.UserModel.CellType.Blank)) { continue; } for (int celNumber = row.FirstCellNum; celNumber < cellCount; celNumber++) { if (row.GetCell(celNumber) != null) { var data = row.GetCell(celNumber).ToString(); switch (celNumber) { case 0: _temp.Name = data; break; case 1: _temp.Price = int.Parse(data); break; case 2: _temp.Ingredents = parseToList(data, _DELIMITER); break; default: return(null); } } } _tempList.Add(_temp); } } } return(_tempList); }
public int RegisterCaterer(Caterer c) { db.Caterers.Add(c); db.SaveChanges(); return(1); }
public ActionResult <string> Create (Caterer model) { string json = null; var stream2 = new MemoryStream(model.Document); IFormFile file = new FormFile(stream2, 0, model.Document.Length, "name", "filename.xlsx"); string folderName = "UploadExcel"; //string webRootPath = _hostingEnvironment.WebRootPath; //string newPath = Path.Combine(webRootPath, folderName); StringBuilder sb = new StringBuilder(); //if (!Directory.Exists(newPath)) //{ // Directory.CreateDirectory(newPath); //} string sFileExtension = Path.GetExtension(file.FileName).ToLower(); List <string> ItemLista = new List <string>(); List <string> IngredientsLista = new List <string>(); if (file.Length > 0) { ISheet sheet; using (var stream = file.OpenReadStream()) { //json = ReadExcelasJSON(stream); stream.Position = 0; if (sFileExtension == ".xls") { HSSFWorkbook hssfwb = new HSSFWorkbook(stream); //This will read the Excel 97-2000 formats sheet = hssfwb.GetSheetAt(0); //get first sheet from workbook } else { XSSFWorkbook hssfwb = new XSSFWorkbook(stream); //This will read 2007 Excel format sheet = hssfwb.GetSheetAt(0); //get first sheet from workbook } IRow headerRow = sheet.GetRow(0); //Get Header Row int cellCount = headerRow.LastCellNum; sb.Append("<table class='table table-bordered'><tr>"); for (int j = 0; j < cellCount; j++) { NPOI.SS.UserModel.ICell cell = headerRow.GetCell(j); if (cell == null || string.IsNullOrWhiteSpace(cell.ToString())) { continue; } sb.Append("<th>" + cell.ToString() + "</th>"); } sb.Append("</tr>"); sb.AppendLine("<tr>"); for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++) //Read Excel File { IRow row = sheet.GetRow(i); if (row == null) { continue; } if (row.Cells.All(d => d.CellType == NPOI.SS.UserModel.CellType.Blank)) { continue; } for (int j = row.FirstCellNum; j < cellCount; j++) { if (row.GetCell(j) != null) { sb.Append("<td>" + row.GetCell(j).ToString() + "</td>"); } } sb.AppendLine("</tr>"); } sb.Append("</table>"); } } //return this.Content(sb.ToString()); List <string> testLista2 = ItemLista; return(sb.ToString()); }