public async Task <IActionResult> PutCalendar(string calendarName, Calendar calendar) { if (calendarName != calendar.CalendarName) { return(BadRequest()); } _context.Entry(calendar).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CalendarExists(calendarName)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// adds a task to the selected day public void AddTask(Day day, string taskName, string taskKeyWords, string taskDescription) { var currentday = SelectDay(day); currentday.TaskName = taskName; currentday.TaskKeyWords = taskKeyWords; currentday.TaskDescription = taskDescription; context.Entry(currentday).CurrentValues. SetValues(context.Days.Where(x => x.date.Equals(currentday.date))); this.context.SaveChanges(); }
public async Task <IActionResult> PutCustomer(int id, Customer customer) { if (id != customer.ID) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTodo(int id, [FromBody] Todo todo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var list = _context.Lists.FirstOrDefaultAsync(p => p.Id == todo.Id); _context.Entry(todo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAppointmentType(int id, AppointmentType appointmentType) { if (id != appointmentType.ID) { return(BadRequest()); } _context.Entry(appointmentType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppointmentTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public int UpdateAccount(Account account) { using (var ctx = new OrganizerContext()) { ctx.Entry(account).State = EntityState.Modified; return(ctx.SaveChanges()); } }
public int UpdateCurrency(Currency currency) { using (var ctx = new OrganizerContext()) { ctx.Entry(currency).State = EntityState.Modified; return(ctx.SaveChanges()); } }
public int UpdateCardCompany(CardCompany cardCompany) { using (var ctx = new OrganizerContext()) { ctx.Entry(cardCompany).State = EntityState.Modified; return(ctx.SaveChanges()); } }
public async Task <ActionResult> Edit([Bind(Include = "Id,Type,Subject,BeginDateTime,EndDateTime,Place,State")] Note note) { if (note.EndDateTime <= note.BeginDateTime) { ModelState.AddModelError("BeginDateTime", "Дата начала должна быть меньше даты конца"); } if (ModelState.IsValid) { db.Entry(note).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(note)); }
public int UpdateMovement(Movement movement) { using (var ctx = new OrganizerContext()) { ctx.Entry(movement).State = EntityState.Modified; return(ctx.SaveChanges()); } }
public async Task <ActionResult> Edit([Bind(Include = "Id,FirstName,LastName,Patronymic,BirthDate,Organization,Position")] Contact contact, List <string> phone, List <string> email, List <string> skype, List <string> other) { if (ModelState.IsValid) { List <ContactInformation> contactInformations = await db.ContactInformations.Where(c => c.ContactId == contact.Id).ToListAsync(); foreach (var item in contactInformations) { db.ContactInformations.Remove(item); } db.Entry(contact).State = EntityState.Modified; await db.SaveChangesAsync(); foreach (string item in phone) { if (item != null && item != "") { db.ContactInformations.Add(new ContactInformation(item, null, null, null, contact.Id)); await db.SaveChangesAsync(); } } foreach (string item in email) { if (item != null && item != "") { db.ContactInformations.Add(new ContactInformation(null, item, null, null, contact.Id)); await db.SaveChangesAsync(); } } foreach (string item in skype) { if (item != null && item != "") { db.ContactInformations.Add(new ContactInformation(null, null, item, null, contact.Id)); await db.SaveChangesAsync(); } } foreach (string item in other) { if (item != null && item != "") { db.ContactInformations.Add(new ContactInformation(null, null, null, item, contact.Id)); await db.SaveChangesAsync(); } } return(RedirectToAction("Index")); } return(View(contact)); }
public async Task <IActionResult> PutList(int id, [FromBody] List list) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = _userManager.GetUserId(User); var existinglist = _context.Lists .Include(q => q.Todos) .FirstOrDefault(q => _context.Lists.Any(r => r.Id == id)); existinglist.IsDone = list.IsDone; existinglist.Name = list.Name; _context.Entry(list).State = EntityState.Modified; await _context.SaveChangesAsync(); return(Ok(existinglist)); }
private void DiaryDone(Diaryes diary) { db.Entry(diary).State = EntityState.Modified; diary.DoneStatus = 1; db.SaveChanges(); }