public async Task <IActionResult> Create(Report report) { if (ModelState.IsValid) { report.DateCreated = DateTime.Now; _context.Add(report); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(report)); }
public string Post(TarjetaRequest data) { Respuesta re = new Respuesta(); Tarjeta ta = null; re.mensaje = ""; try { ta = _context.Tarjeta.First(t => t.Numero == data.numero); } catch { re.mensaje = "La tarjeta no existe"; } if (ta is not null) { Movimiento mov = new Movimiento(); mov.idTarjeta = ta.idTarjeta; mov.Importe = 0; mov.TipoOperacion = "Balance"; mov.fecha = DateTime.Now; re.obj = mov; _context.Add(mov); _context.SaveChanges(); } return(JsonConvert.SerializeObject(re)); }
public void SaveZipCodeToSearchHistory(int memberId, string zipCode) { using (var transaction = _context.Database.BeginTransaction()) { try { var check = _context.UserHistory.Where(zip => zip.ZipCode.Equals(zipCode) && zip.MemberId == memberId); //ensure data integrity. if (check.Count <SearchHistory>() == 0) { SearchHistory item = new SearchHistory() { MemberId = memberId, ZipCode = zipCode }; _context.Add(item); Task task = _context.SaveChangesAsync(); task.Wait(); transaction.Commit(); } } catch (DbUpdateConcurrencyException) { transaction.Rollback(); throw; } } }
public IActionResult Register(UserViewModel formUser) { if (ModelState.IsValid) { User newUser = new User { firstName = formUser.firstName, lastName = formUser.lastName, email = formUser.email, password = formUser.password }; User emailExistsQuery = _context.Users.SingleOrDefault(user => user.email == formUser.email); if (emailExistsQuery != null) { ViewBag.ExistsError = "User with this email already exists, please choose a different email"; return(View("LoginReg")); } else { PasswordHasher <User> Hasher = new PasswordHasher <User>(); newUser.password = Hasher.HashPassword(newUser, newUser.password); _context.Add(newUser); _context.SaveChanges(); User results = _context.Users.SingleOrDefault(user => user.email == formUser.email); HttpContext.Session.SetInt32("loggedId", results.UserId); return(RedirectToAction("LandingPage", "Landing")); } } else { return(View("LoginReg")); } }
public ActionResult Create([Bind("MenuID,CategoryID,Content,ContentType,CreatedBy,CreatedDate,IsDeleted,MenuDescription,MenuName,MenuPrice,StatusID,UpdatedBy,UpdatedDate")] Menu menu, ICollection <IFormFile> files) { if (ModelState.IsValid) { //var uploads = Path.Combine(_environment.WebRootPath, "uploads"); foreach (var file in files) { if (file.Length > 0) { using (var fileStream = file.OpenReadStream()) using (var ms = new MemoryStream()) { fileStream.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); menu.Content = fileBytes; menu.ContentType = file.ContentType; // act on the Base64 data } } } menu.CreatedBy = "Admin"; menu.CreatedDate = DateTime.Now; _context.Add(menu); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewData["CategoryID"] = new SelectList(_context.Category, "CategoryID", "CategoryName", menu.CategoryID); ViewData["StatusID"] = new SelectList(_context.Status, "StatusID", "StatusName", menu.StatusID); return(View(menu)); }
public IActionResult Register(UserViewModel FormUser) { if (ModelState.IsValid) { User NewUser = new User { FirstName = FormUser.FirstName, LastName = FormUser.LastName, Email = FormUser.Email, Password = FormUser.Password }; User emailExistsQuery = _context.Users.SingleOrDefault(user => (user.Email == FormUser.Email)); if (emailExistsQuery != null) { ViewBag.ExistsError = "User with this email already exists, please choose a different email"; return(View("LoginReg")); } else { PasswordHasher <User> Hasher = new PasswordHasher <User>(); NewUser.Password = Hasher.HashPassword(NewUser, NewUser.Password); _context.Add(NewUser); _context.SaveChanges(); User results = _context.Users.SingleOrDefault(user => (user.Email == FormUser.Email)); int id = results.UserID; HttpContext.Session.SetInt32("logged_id", id); return(RedirectToAction("ShowDashboard", "Activity")); } } return(View("LoginReg")); }
public async Task <ActionResult> Create([FromBody] judge judgeObject) { if (judgeObject.EmailAddress.Length == 0) { return(BadRequest(new { Message = "Judge record cannot be created. Email is missing." })); } else if (judgeObject.JudgeName.Length == 0) { return(BadRequest(new { Message = "Judge record cannot be created. Judge Name is missing." })); } else if (judgeObject.AICupperAccountID == null) { return(BadRequest(new { Message = "Judge record cannot be created. AICUPPER Account is missing." })); } else { try { _context.Add(judgeObject); await Task.Run(() => _context.SaveChangesAsync()); return(Accepted(new { Message = "Judge record successfully created" })); } catch (Exception ex) { return(StatusCode(500)); } } }
public async Task <IActionResult> Create([Bind("Id,Name,Price,PhotoUrl,Category,Details")] MyapiProduct myapiProduct) { if (ModelState.IsValid) { _context.Add(myapiProduct); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(myapiProduct)); }
public ActionResult Create([Bind("BillID,BillDate,CreatedBy,CreatedDate,IsDeleted,OrderID,TotalPrice,UpdatedBy,UpdatedDate")] Bill bill) { if (ModelState.IsValid) { _context.Add(bill); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewData["OrderID"] = new SelectList(_context.Order, "OrderID", "OrderID", bill.OrderID); return(View(bill)); }
public async Task <IActionResult> Create([Bind("UserName,Userpassword,Role")] Demo demo) { if (ModelState.IsValid) { _context.Add(demo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(demo)); }
public ResponseViewModel PayOrder(int id) { Bill bill = new Bill(); bill.OrderID = id; bill.BillDate = DateTime.Now; var orderitem = _context.OrderItem.Include(m => m.Menu).Include(m => m.Order).Where(a => a.OrderID == id && a.IsDeleted != true && a.Status != "Cancel").ToList(); double total = 0; foreach (var item in orderitem) { total = total + (item.Qty * Convert.ToDouble(item.Menu.MenuPrice)); item.Status = "Paid"; _context.Update(item); } total = (total * 0.1) + total; bill.TotalPrice = total.ToString(); bill.CreatedBy = "Admin"; bill.CreatedDate = DateTime.Now; _context.Add(bill); var order = _context.Order.Include(m => m.Type).SingleOrDefault(m => m.OrderID == id); order.Finish = true; order.UpdateDate = DateTime.Now; order.UpdatedBy = "Admin"; _context.Update(order); if (order.Type.TypeName == "Order") { var tableid = (from a in _context.Track where a.OrderID == order.OrderID select a.TableID).FirstOrDefault(); var table = _context.Table.Find(tableid); table.TableStatus = "NotOccupied"; _context.Update(table); } if (_context.SaveChanges() > 0) { return(new ResponseViewModel { Status = true }); } else { return(new ResponseViewModel { Status = false }); } }
public async Task <IActionResult> Create([Bind("Id,EmployeeName,EmployeeStatus,Salary,PayBasis,PositionTitle")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("Id,NmName,DsEmail")] TbUser tbUser) { if (ModelState.IsValid) { _context.Add(tbUser); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tbUser)); }
public async Task <IActionResult> Create(Churrasco churrasco) { if (ModelState.IsValid) { _context.Add(churrasco); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), new { id = churrasco.ChurrascoID })); } return(View(churrasco)); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,LogoUrl")] MyapiRestaurant myapiRestaurant) { if (ModelState.IsValid) { _context.Add(myapiRestaurant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(myapiRestaurant)); }
public async Task <IActionResult> Create(Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("UserName,Userpassword")] Demo demo) { if (ModelState.IsValid) { _context.Add(demo); await _context.SaveChangesAsync(); return(RedirectToAction("Login", "Account")); } return(View(demo)); }
public IActionResult Registro(Menu x) { if (ModelState.IsValid) { _context.Add(x); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(x)); }
public async Task <IActionResult> Create(Participante participante) { if (ModelState.IsValid) { _context.Add(participante); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), "Churrascos", new { id = participante.ChurrascoID })); } return(View(participante)); }
public async Task <IActionResult> Create([Bind("CategoryId,CategoryName,Description")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public ActionResult Create([Bind("StatusID,CreatedBy,CreatedDate,IsDeleted,StatusName,UpdatedBy,UpdatedDate")] Status status) { if (ModelState.IsValid) { status.CreatedBy = "Admin"; status.CreatedDate = DateTime.Now; _context.Add(status); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(status)); }
public ActionResult Create([Bind("CategoryID,CategoryName,CreatedBy,CreatedDate,IsDeleted,UpdatedBy,UpdatedDate")] Category category) { if (ModelState.IsValid) { category.CreatedBy = "Admin"; category.CreatedDate = DateTime.Now; _context.Add(category); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind("TableID,CreatedBy,CreatedDate,IsDeleted,TableName,TableStatus,UpdatedBy,UpdatedDate")] Table table) { if (ModelState.IsValid) { table.CreatedBy = "Admin"; table.CreatedDate = DateTime.Now; _context.Add(table); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(table)); }
public ActionResult Create([Bind("TypeID,CreatedBy,CreatedDate,IsDeleted,TypeName,UpdatedBy,UpdatedDate")] Model.Type @type) { if (ModelState.IsValid) { @type.CreatedBy = "Admin"; @type.CreatedDate = DateTime.Now; _context.Add(@type); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(@type)); }
public async Task <IActionResult> Create([Bind("OrderID,CreatedBy,CreatedDate,Finish,IsDeleted,Name,OrderDate,TypeID,UpdateDate,UpdatedBy")] Order order) { if (ModelState.IsValid) { _context.Add(order); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["TypeID"] = new SelectList(_context.Type, "TypeID", "TypeName", order.TypeID); return(View(order)); }
public async Task <IActionResult> Create([Bind("Id,IssueTime,CustomerId,RestaurantId,IssueDate,PlannedTime,PlannedDate")] MyapiOrder myapiOrder) { if (ModelState.IsValid) { _context.Add(myapiOrder); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.MyapiCustomers, "Id", "Email", myapiOrder.CustomerId); ViewData["RestaurantId"] = new SelectList(_context.MyapiRestaurants, "Id", "Address", myapiOrder.RestaurantId); return(View(myapiOrder)); }
public IActionResult CreateEditUSer(UserTable model) { if (model.Id == 0) { _dbContext.Add(model); } else { _dbContext.Update(model); } _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <CreateMerchantCommandDto> Handle(CreateMerchantCommand request, CancellationToken cancellationToken) { var merchant = new Domain.Models.MerchantD { name = request.DataD.Attributes.name, address = request.DataD.Attributes.address }; _context.Add(merchant); await _context.SaveChangesAsync(cancellationToken); return(new CreateMerchantCommandDto { Success = true, Message = "Creator successfully created", }); }
public async Task <IActionResult> Create([Bind("Enemail,Ennombre,Encalificacion")] Encuesta encuesta) { if (ModelState.IsValid) { encuesta.Enfecha = DateTime.Now.Date; Encuesta record = _context.Encuesta.FindAsync(encuesta.Enfecha, encuesta.Enemail).Result; if (ServicesEncuesta.puedeRegistrar(record, encuesta)) { _context.Add(encuesta); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { ViewBag.Mensaje = "El email ya está ha registrado una calificacion el día de hoy."; return(View()); } } return(View(encuesta)); }
public void AddUser(User user) { _userDbEntities.Add(user); }