public async Task <IActionResult> Create([Bind("ID,PartName,PartType,SKU,Quantity,SuggestedQuantity,MinimumQuantity,UnitCost,Location,Barcode,Status")] Inventory inventory) { Console.WriteLine(inventory.ID); if (ModelState.IsValid) { if (HttpContext.User.IsInRole("Admin")) { inventory.Status = Inventory.InventoryStatus.Approved; } else { inventory.Status = Inventory.InventoryStatus.Submitted; } Console.WriteLine("status"); Console.WriteLine(inventory.Status); _context.Add(inventory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(inventory)); }
public virtual async Task <ActionResult> Post([FromBody] ModelType model) { set.Add(model); await context.SaveChangesAsync(); return(new OkResult()); }
public async Task <IActionResult> PutReview(int id, [FromForm] Review review) { if (id != review.Id) { return(BadRequest()); } var newReview = new Review { BookId = review.BookId, ReviewerName = review.ReviewerName, Rating = review.Rating, Comment = review.Comment }; _context.Entry(review).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReviewExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutReview(int id, [FromForm] Review review) { if (id != review.Id) { return(BadRequest()); } _context.Entry(review).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReviewExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("DepartmentID,Name,PhoneNumber")] Department department) { if (ModelState.IsValid) { _context.Add(department); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Create([Bind("CardID,Name,Set,Id,Civilization,Rarity,Type,Cost,Text,Flavor,Illustrator,Race,Power,Races0,Races1,Civilizations0,Civilizations1")] DMCard dMCard) { if (ModelState.IsValid) { _context.Add(dMCard); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(dMCard)); }
public async Task <IActionResult> Create([Bind("ID,Description,CreatedDate,Done")] Todo todo) { if (ModelState.IsValid) { _context.Add(todo); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(todo)); }
public async Task <IActionResult> Create([Bind("note_id,category,main_name,long_description,tags")] NoteSet adres) { if (ModelState.IsValid) { _context.Add(adres); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(adres)); }
public async Task <IActionResult> Create([Bind("ID,Company,Price,CreatedDate")] Invoice invoice) { if (ModelState.IsValid) { _context.Add(invoice); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(invoice)); }
public async Task <IActionResult> Create([Bind("ID,Name,Street,Housenumber,Zipcode,City,Phonenumber,Lat,Lng")] Store store) { if (ModelState.IsValid) { _context.Add(store); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(store)); }
public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,Degree,GameProject,SkillsLink,ProfileLink")] Member member) { if (ModelState.IsValid) { _context.Add(member); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(member)); }
public async Task <IActionResult> Create([Bind("ID,Name,Category,Engineer,Link")] Game game) { if (ModelState.IsValid) { _context.Add(game); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(game)); }
public async Task <IActionResult> Create([Bind("klient_id,imie,nazwisko,saldo")] Klient adres) { if (ModelState.IsValid) { _context.Add(adres); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(adres)); }
public async Task <IActionResult> Create([Bind("ID,Name,Address,Email,Comment")] Profile profile) { if (ModelState.IsValid) { _context.Add(profile); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(profile)); }
public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,FullAddress,MailingAddress,AsAboveAddress,EmailAddress,PhoneNumber,CitizenStatus,EmploymentStartDate,EmploymentType,PositionTitle,EmergencyContactName,EmergencyContactRelationship,EmergencyContactPhoneNumber,EmployeeSignature")] Todo todo) { if (ModelState.IsValid) { _context.Add(todo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(todo)); }
public async Task <IActionResult> Create([Bind("adres_id,miast,ulicac,nrDomy,kodPocztowy,adres_klient_id")] Adres adres) { if (ModelState.IsValid) { _context.Add(adres); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(adres)); }
public async Task <IActionResult> Create([Bind("ID,Title,ReleaseDate,Genre,Price,Rating")] Movie movie) { if (!ModelState.IsValid) { return(View(movie)); } _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("EmployeeID,Name,DepartmentID,Email,PhoneNumber")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DepartmentID"] = new SelectList(_context.Department, "DepartmentID", "Name", employee.DepartmentID); return(View(employee)); }
public async Task <ActionResult> Create([Bind(Include = "CustomerID,FirstName,LastName,MiddleName,StreetAddress,City,ZipCode,State,BirthDate,CreditCard_Number,CreditCard_Expiration,CreditCard_Code")] CustomerModel customer) { if (ModelState.IsValid) { db.Customers.Add(customer); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(customer)); }
public async Task <IActionResult> Create([Bind("ID,Description,CreatedDate")] Todo todo) { _logger.LogInformation("Async create called successfully."); if (ModelState.IsValid) { _context.Add(todo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(todo)); }
public async Task <IActionResult> GetAsync([FromForm] Tester data) { var grades = new List <Grade> { new Grade { Score = 10 }, new Grade { Score = 11 }, new Grade { Score = 12 }, new Grade { Score = 13 } }; var student = new Student { Name = "john", Age = 12, Grades = grades }; _context.Student.Add(student); await _context.SaveChangesAsync(); var val = await _context.Student.AsNoTracking() .Select(stu => new StudentObject { ID = stu.ID, Grades = stu.Grades.ToList(), Age = stu.Age, Name = stu.Name }) .Take(100) .ToListAsync(); _queue.QueueTask(async token => { await Task.Delay(1000); _logger.LogInformation("Sub Task"); await Task.Delay(1000); _logger.LogInformation("Done"); }); _queue.QueueTask(async token => { await Task.Delay(1000); _logger.LogInformation("Sub Task2"); await Task.Delay(1000); _logger.LogInformation("Done2"); }); return(Ok(new { Message = val })); }
/// <summary> /// 更改某个id相同的Task的信息 /// </summary> /// <param name="updateTask"></param> /// <returns></returns> public async Task <bool> UpdateTaskAsync(MyDatabaseContext.Task updateTask) { using (var db = new MyDatabaseContext()) { var task = await db.Tasks.SingleOrDefaultAsync(m => m.ID == updateTask.ID); if (task != null) { task.Date = updateTask.Date; task.Begin = updateTask.Begin; task.DefaultTime = updateTask.DefaultTime; task.FinishTime = updateTask.FinishTime; task.FinishFlag = updateTask.FinishFlag; task.UserID = updateTask.UserID; task.Introduction = updateTask.Introduction; await db.SaveChangesAsync(); return(true); } else { return(false); } } }
/// <summary> /// 新增黑名单进程 /// </summary> /// <param name="newBLProgress"></param> /// <returns></returns> public async Task <bool> AddBlackListProgressAsync(MyDatabaseContext.BlackListProgress newBLProgress) { using (var db = new MyDatabaseContext()) { MyDatabaseContext.BlackListProgress Announcement; if (newBLProgress.Type == 2) { Announcement = await db.BlackListProgresses.SingleOrDefaultAsync(m => m.Uwp_ID.Equals(newBLProgress.ID)); } else { Announcement = await db.BlackListProgresses.SingleOrDefaultAsync(m => m.FileName == newBLProgress.FileName && m.Type == newBLProgress.Type); } if (Announcement == null) { db.BlackListProgresses.Add(newBLProgress); await db.SaveChangesAsync(); return(true); } else { await new DialogService().ShowAsync("程序已存在!"); return(false); } } }
public async Task <IActionResult> Register([FromForm] RegistrationModel model) { if (ModelState.IsValid) { model.DateOfRegistration = DateTime.Now; _context.Add(model); await _context.SaveChangesAsync(); var result = _context.Registration.Where(x => x.Email == model.Email).FirstOrDefault(); var complete = new CompleteRegisterViewmodel() { RegisterDate = result.DateOfRegistration.ToString("yyyy-MM-dd"), CustomerName = $"{result.LastName}, {result.FirstName}", SubscriptionType = result.SubscriptionType, Username = result.Username }; return(View("CompleteRegister", complete)); } var registerModel = new RegistrationModel(); return(View(registerModel)); }
public async Task <bool> DeleteTaskAsync(String userName, int date, String begin) { using (var db = new MyDatabaseContext()) { var currentUser = await db.Users.FirstOrDefaultAsync(m => m.UserName == userName); if (currentUser != null) { var task = await db.Tasks.SingleOrDefaultAsync(m => m.Date == date && m.Begin == begin && m.UserId == currentUser.Id); if (task != null) { db.Tasks.Remove(task); await db.SaveChangesAsync(); return(true); } else { return(false); } } else { return(false); } } }
public async Task <bool> UpdateTaskAsync(String userName, int date, String begin, String end, int defaultTime, int finish, int totalTime, String introduction) { using (var db = new MyDatabaseContext()) { var currentUser = await db.Users.FirstOrDefaultAsync(m => m.UserName == userName); if (currentUser != null) { var task = await db.Tasks.SingleOrDefaultAsync(m => m.Date == date && m.Begin == begin && m.UserId == currentUser.Id); if (task != null) { task.DefaultTime = defaultTime; task.End = end; task.Finish = finish; task.Introduction = introduction; task.TotalTime = totalTime; await db.SaveChangesAsync(); return(true); } else { return(false); } } else { return(false); } } }
public async Task <IActionResult> Create([Bind("ID,Description,CreatedDate")] Todo todo) { try { if (ModelState.IsValid) { _context.Add(todo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(todo)); } catch (Exception ex) { return(null); } }
public async Task <IActionResult> DeleteConfirmed(int id) { var dMCard = await _databasecontext.DMCards.FindAsync(id); _databasecontext.DMCards.Remove(dMCard); await _databasecontext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("ID,Description,CreatedDate")] Todo todo) { if (ModelState.IsValid) { if (todo.Description.Contains("Bad")) { throw new Exception("Bad words are not allowed"); } else { _context.Add(todo); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } } return(View(todo)); }
<Microsoft.AspNetCore.Mvc.IActionResult> DeleteConfirmed(System.Guid?id) { Models.Cms.PostCategory postCategory = await MyDatabaseContext.PostCategories .FirstOrDefaultAsync(m => m.Id == id.Value); MyDatabaseContext.PostCategories.Remove(postCategory); await MyDatabaseContext.SaveChangesAsync(); return(RedirectToAction(actionName: nameof(Index))); }