// Adds a new metric to the system. public bool AddNewMetric(MetricViewModel metric) { var fy = _context.FiscalYears.FirstOrDefault(f => f.FiscalYearID == metric.FiscalYearID); var metricToBeSaved = new Metric() { MetricID = metric.MetricID, MetricCategory = metric.MetricCategory, MetricName = metric.MetricName, Description = metric.Description, FiscalYear = fy }; _context.Metrics.Add(metricToBeSaved); var response = _context.SaveChanges(); if (response > 0) { return(true); } else { return(false); } }
public bool AddNewAppointment(AppointmentViewModel appointment) { // Load Workload object to save. var workload = _context.WorkloadBacklogs.FirstOrDefault(wb => wb.WBID == appointment._AppointmentWorkloadWBID); // Load UserKanban object to save. var user = _context.Users.FirstOrDefault(u => u.UniqueName == appointment._AppointmentUserUniqueName); var appointmentToBeSaved = new Appointment() { AppointmentID = appointment._AppointmentID, AppointmentWorkload = workload, AppointmentDate = appointment._AppointmentDate, AppointmentHoursDispensed = appointment._AppointmentHoursDispensed, AppointmentTE = appointment._AppointmentTE, AppointmentUser = user, AppointmentComment = appointment._AppointmentComment }; _context.Appointments.Add(appointmentToBeSaved); var response = _context.SaveChanges(); // setting the last appointment inside the repository SetLastAppointment(appointment._AppointmentWorkloadWBID, appointment._AppointmentID); if (response > 0) { return(true); } else { return(false); } }
public ListDto AddList(AddListDto addListDto) { if (!_context.Boards.Any(x => x.Id == addListDto.BoardId)) { return(null); } var list = new List { Name = addListDto.Name, BoardId = addListDto.BoardId }; _context.Lists.Add(list); _context.SaveChanges(); var listDto = new ListDto { Id = list.Id, BoardId = list.BoardId, Name = list.Name }; return(listDto); }
public CardDto AddCard(AddCardDto addCardDto) { if (!ListExists(addCardDto.ListId)) { return(null); } var card = new Card { Name = addCardDto.Name, ListId = addCardDto.ListId }; _context.Cards.Add(card); var resultOfAdding = _context.SaveChanges(); if (resultOfAdding == 0) { return(null); } var cardDto = _mapper.Map <CardDto>(card); return(cardDto); }
// Adds a new fiscal year to the system. public bool AddNewFiscalYear(FiscalYearViewModel fiscalyear) { try { var fiscalYearToBeSaved = new FiscalYear() { FiscalYearID = fiscalyear.FiscalYearID, FullNumericFiscalYear = fiscalyear.FullNumericFiscalYearMain, TextualFiscalYear = fiscalyear.TextualFiscalYearMain }; _context.FiscalYears.Add(fiscalYearToBeSaved); var response = _context.SaveChanges(); if (response > 0) { return(true); } else { return(false); } } catch (Exception) { return(false); } }
public string Post([FromBody] Board board) { if (ModelState.IsValid) { _db.Boards.Add(board); _db.SaveChanges(); return("Successfully Added Board"); } return(ModelState.ValidationState.ToString()); }
public async Task <ActionResult> Create(Project project) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); project.User = currentUser; _db.Projects.Add(project); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,Name,BoardId")] Column column) { if (ModelState.IsValid) { db.Columns.Add(column); db.SaveChanges(); return(RedirectToAction("Show", "BoardViewModel", new { id = column.BoardId })); } return(View(column)); }
public bool AddNewUser(UserKanbanViewModel user) { _context.Users.Add(new User() { UniqueName = user.UniqueName, Name = user.Name }); _context.SaveChanges(); return(true); }
public BoardDto CreateBoard(CreateBoardDto createBoardDto) { var board = new Board() { Name = createBoardDto.Name }; _context.Boards.Add(board); _context.SaveChanges(); return(ConstructBoardDto(board)); }
public void CreateTask(int id, Task task) { //check where the board id is valid and then then inser task to table task.BoardId = id; if (_kanbanContext.Statuses.Where(s => s.StatusId == task.StatusId).First() != null && _kanbanContext.Tags.Where(t => t.TagId == task.TagId).First() != null) { _kanbanContext.Tasks.Add(task); } _kanbanContext.SaveChanges(); }
//Insert the board data into the database public void CreateBoard(Board board, string userName) { //save changes to the board and boarduser var retrievedUser = _kanbanContext.Users.Where(u => u.Username == userName).First(); board.BoardUsers = new List <BoardUser> { new BoardUser { Board = board, User = retrievedUser, Role = BoardUserRole.Owner.ToString() } }; _kanbanContext.Boards.Add(board); _kanbanContext.SaveChanges(); }
// public ActionResult AddTicket(Ticket ticket) public ActionResult AddTicket([FromBody] Ticket ticket) { ticket.Id = Guid.NewGuid().ToString(); db.Tickets.Add(ticket); db.SaveChanges(); return(Content("Success :)")); }
public CardDto AddCard(AddCardDto addCardDto) { if (!_context.Lists.Any(x => x.Id == addCardDto.ListId)) { return(null); } var card = new Card() { Name = addCardDto.Name, ListId = addCardDto.ListId }; _context.Cards.Add(card); _context.SaveChanges(); var cardDto = new CardDto { Id = card.Id, ListId = card.ListId, Name = card.Name }; return(cardDto); }
public ActionResult Create([Bind(Include = "Id,Name,Description,ProjectId,ColumnId,Position,CreatedDate,UpdatedDate")] Issue issue) { if (ModelState.IsValid) { issue.Position = 0; issue.CreatedDate = DateTime.Now; issue.UpdatedDate = DateTime.Now; db.Issues.Add(issue); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ColumnId = new SelectList(db.Columns, "Id", "Name", issue.ColumnId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", issue.ProjectId); return(View(issue)); }
public ActionResult Create([Bind(Include = "Id,Name,Description")] Project project) { if (ModelState.IsValid) { db.Projects.Add(project); db.SaveChanges(); var board = new Board(); board.ProjectId = project.Id; db.Boards.Add(board); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public async Task <ActionResult> Create(Manager manager, int ProjectId) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var currentUser = await _userManager.FindByIdAsync(userId); manager.User = currentUser; _db.Managers.Add(manager); if (ProjectId != 0) { _db.ProjectManagers.Add(new ProjectManager() { ProjectId = ProjectId, ManagerId = manager.ManagerId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }
public ListDto AddList(AddListDto addListDto) { if (!_context.Boards.Any(x => x.Id == addListDto.BoardId)) { return(null); } var list = new List { Name = addListDto.Name, BoardId = addListDto.BoardId }; _context.Lists.Add(list); _context.SaveChanges(); return(ConstructListDto(list)); }
public bool AddNewUser(UserKanbanViewModel user) { try { _context.Users.Add(new User() { UniqueName = user.UniqueName, Name = user.Name }); _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool AddNewAppointment(AppointmentViewModel appointment) { // Load Workload object to save. var workload = _context.WorkloadBacklogs.FirstOrDefault(wb => wb.WBID == appointment._AppointmentWorkloadWBID); // Load UserKanban object to save. var user = _context.Users.FirstOrDefault(u => u.UniqueName == appointment._AppointmentUserUniqueName); var appointmentToBeSaved = new Appointment() { AppointmentID = appointment._AppointmentID, AppointmentWorkload = workload, AppointmentDate = appointment._AppointmentDate, AppointmentHoursDispensed = appointment._AppointmentHoursDispensed, AppointmentTE = appointment._AppointmentTE, AppointmentUser = user, AppointmentComment = appointment._AppointmentComment }; _context.Appointments.Add(appointmentToBeSaved); var response = _context.SaveChanges(); // setting the last appointment inside the repository SetLastAppointment(appointment._AppointmentWorkloadWBID, appointment._AppointmentID); if (response > 0) { //Queueing the message to be sent EmailClient emailClient = new EmailClient(); emailClient.EmailTo = user.UniqueName; emailClient.EmailTitle = "New appointment attributed to you"; emailClient.EmailMessage = "One new appointment was assigned to you. Plese, check out you dashboard."; var callResponse = Arda.Common.Utils.Util.QueuesEmailMessage("https://arda-function-app.azurewebsites.net/api/AddsMessageToAzureQueueStorage?code=njN1vpdKv6eiMBCs/SLwK9Mdeu8LiMmB5xRr2uLaCyfGvzwUrnK05g==", HttpMethod.Post, emailClient).Result; return(true); } else { return(false); } }
public ActionResult Create([Bind(Include = "Id,Name,Description,ProjectId,ColumnId,Position,CreatedDate,UpdatedDate")] IssueViewModel issueViewModel) { if (ModelState.IsValid) { Issue issue = new Issue(); issue.Id = issueViewModel.Id; issue.Name = issueViewModel.Name; issue.Description = issueViewModel.Description; issue.ProjectId = issueViewModel.ProjectId; issue.ColumnId = issueViewModel.ColumnId; issue.Position = db.Issues.Where(c => c.ColumnId == issue.ColumnId).Count() + 1; issue.CreatedDate = DateTime.Now; issue.UpdatedDate = DateTime.Now; db.Issues.Add(issue); db.SaveChanges(); return(RedirectToAction("Show", "BoardViewModel", new { id = issue.ProjectId })); } return(View(issueViewModel)); }
public ActionResult Edit([Bind(Include = "Id")] Board board) { if (ModelState.IsValid) { db.Entry(board).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Projects, "Id", "Name", board.Id); return(View(board)); }
public void AssignTag(Guid wbid, string tag) { WorkloadBacklogTags workloadTag = new WorkloadBacklogTags() { TagId = tag, WorkloadBacklogWBID = wbid }; _context.Tags.Add(workloadTag); _context.SaveChanges(); }
public ActionResult SendToBacklog(int?issueId) { if (issueId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Issue issue = db.Issues.Find(issueId); if (issue == null) { return(HttpNotFound()); } issue.ColumnId = null; issue.Position = 0; issue.UpdatedDate = DateTime.Now; db.Entry(issue).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Show", new { id = issue.ProjectId })); }
public bool AddNewAppointment(AppointmentViewModel appointment) { try { // Load Workload object to save. var workload = _context.WorkloadBacklogs.FirstOrDefault(wb => wb.WBID == appointment._AppointmentWorkloadWBID); // Load UserKanban object to save. var user = _context.Users.FirstOrDefault(u => u.UniqueName == appointment._AppointmentUserUniqueName); var appointmentToBeSaved = new Appointment() { AppointmentID = appointment._AppointmentID, AppointmentWorkload = workload, AppointmentDate = appointment._AppointmentDate, AppointmentHoursDispensed = appointment._AppointmentHoursDispensed, AppointmentTE = appointment._AppointmentTE, AppointmentUser = user, AppointmentComment = appointment._AppointmentComment }; _context.Appointments.Add(appointmentToBeSaved); var response = _context.SaveChanges(); if (response > 0) { return(true); } else { return(false); } } catch (Exception e) { return(false); throw new Exception(e.StackTrace); } }
public ActionResult Create([Bind(Include = "SectionID,Title,Content,CardColor")] Card card, string CategoryName = "", string TagName = "") { Section section = db.Sections.Find(card.SectionID); if (section == null) { return(HttpNotFound()); } if (ModelState.IsValid) { if (section.Board.OwnerID != User.Identity.GetUserId()) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } card.Title = card.Title.Trim(); db.Cards.Add(card); db.SaveChanges(); return(RedirectToAction("Index", "Boards", new { id = section.BoardID })); } return(RedirectToAction("Index", "Boards", new { id = section.BoardID, errMessage = "Could not create card, model not vaild" })); }
public ActionResult Create([Bind(Include = "ID,BoardID,Title")] Section section) { if (ModelState.IsValid) { Board board = db.Boards.Find(section.BoardID); if (board == null) { return(HttpNotFound()); } if (board.OwnerID != User.Identity.GetUserId()) { return(new HttpStatusCodeResult(HttpStatusCode.Forbidden)); } section.Order = board.Sections.Count() + 1; section.ParentID = 0; // new sections start at the top level section.Title = section.Title.Trim(); db.Sections.Add(section); db.SaveChanges(); return(RedirectToAction("Index", "Boards", new { id = section.BoardID, sectionOpen = true })); } return(RedirectToAction("Index", "Boards", new { id = section.BoardID, errMessage = "Could not create section, model not vaild", sectionOpen = true })); }
private static void Seed(KanbanContext context) { if (context.Usuario.FirstOrDefault(x => x.Login == "letscode") == null) { context.Usuario.Add(new Usuario { UserId = Guid.NewGuid(), Login = "******", Senha = "lets@123" }); context.SaveChanges(); } }
public static void ResetIssuesPosition(int columnId) { KanbanContext db = new KanbanContext(); var issues = db.Issues.Where(c => c.ColumnId == columnId).OrderBy(p => p.Position).ToList(); int position = 1; foreach (Issue iss in issues) { iss.Position = position; db.Entry(iss).State = EntityState.Modified; position++; } db.SaveChanges(); }
public ActionResult Create([Bind(Include = "ID,Title")] Board board) { if (ModelState.IsValid) { board.OwnerID = User.Identity.GetUserId(); db.Boards.Add(board); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(board)); }