public async Task <IActionResult> PutProject(int id, Project project) { if (id != project.Id) { return(BadRequest()); } _context.Entry(project).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("UserId,Email,UserPassword")] UserInfo userInfo) { if (ModelState.IsValid) { _context.Add(userInfo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(userInfo)); }
public async Task <OperationResult> CreateAsync(City entityToCreate) { entityToCreate.CreatedAt = DateTime.Now; entityToCreate.ModifiedAt = DateTime.Now; var newCity = _mapper.Map <Entities.City>(entityToCreate); await _context.Cities.AddAsync(newCity); await _context.SaveChangesAsync(); return(OperationResult.Succeeded()); }
public async Task <IActionResult> Create([Bind("TaskNumber,TaskDesc,TaskDueDate,StartDate,TaskStatus,UserId")] TaskInfo taskInfo) { if (ModelState.IsValid) { _context.Add(taskInfo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["UserId"] = new SelectList(_context.UserInfo, "UserId", "Email", taskInfo.UserId); return(View(taskInfo)); }
public async Task <bool> AddUser(User userToAdd) { try { await _taskDB.User.AddAsync(userToAdd); await _taskDB.SaveChangesAsync(); return(true); } catch { return(false); } }
public async Task <bool> AddDepartment(Department departmentToAdd) { try { await _taskDB.Department.AddAsync(departmentToAdd); await _taskDB.SaveChangesAsync(); return(true); } catch { return(false); } }
public async Task <Visits> SaveVisit(Visits visits) { try { visits.VisitDate = DateTime.Now; await _Context.Visits.AddAsync(visits); await _Context.SaveChangesAsync(); return(visits); } catch { return(null); } }
public async Task <IActionResult> PutTask(int id, Models.Task task) { task.id = id; _context.Entry(task).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> AddContanctLogAsync(string message) { var toBeSendedMessages = await _context.Contacts .Where(contact => !contact.ContactLogs.Any(contactLog => contactLog.Contact == contact)) .Include(c => c.ContactLogs) .Take(TakeNumber) .ToListAsync(); if (toBeSendedMessages.Count == ZeroValue) { return(false); } toBeSendedMessages.ForEach(contact => contact.ContactLogs.Add(ContactLog.New(message))); await _context.SaveChangesAsync(); return(true); }