public async Task <IActionResult> EditScope(EditScopeViewModel scope) { // INCREMENT SCOPE VERSION var NewScope = new ScopeModel { ProjectId = scope.ProjectId, ParentScope = scope.ScopeParent, ScopeAuthor = scope.ScopeAuthor, ScopeExpectations = scope.UpdatedScopeExpectations, ScopeGoals = scope.UpdatedScopeGoals, ScopeLimitations = scope.UpdatedScopeLimitations, ScopeManager = scope.ScopeManager, ScopeSummary = scope.UpdatedScopeSummary, ScopeVersion = _context.Scopes.Where(S => S.ProjectId == scope.ProjectId).Count(), ScopeMaxPhaseNumber = scope.UpdatedScopePhaseNumberMax, ScopePhaseNumber = scope.UpdatedScopePhaseNum, ScopePhase = scope.UpdatedScopePhase, ScopeEndDate = scope.ScopeEndDate, ScopeStartDate = scope.ScopeStartDate, }; _context.Scopes.Add(NewScope); await _context.SaveChangesAsync(); ViewData["Msg"] = "Updated Scope and Added to Database"; return(RedirectToAction("Index")); }
public async Task <ToDo> CreateAsync(ToDo toDo) { _projectDbContext.ToDos.Add(toDo); await _projectDbContext.SaveChangesAsync(); return(toDo); }
public async Task <IActionResult> PutStudent(Guid id, Student student) { if (id != student.Id) { return(BadRequest()); } _context.Entry(student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <int> Create( string name, string description, decimal price, string userId, string[] images) { var advertisement = new Advertisement { Name = name, Description = description, Price = price, UserId = userId, CategoryId = 1, }; await _db.AddAsync(advertisement); await _db.SaveChangesAsync(); await _db.AddRangeAsync(images .Select(i => new AdvertisementImage { AdvertisementId = advertisement.Id, ImageString = i, SmallImageString = _imageSizeReducer.GetReducedSizeImage(i, 150, 150), })); await _db.SaveChangesAsync(); return(advertisement.Id); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Abrv")] VehicleMake vehicle) { if (id != vehicle.Id) { return(NotFound()); } if (ModelState.IsValid) { try { DbContext.Update(vehicle); await DbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleMakeExists(vehicle.Id)) { return(NotFound()); } } return(RedirectToAction(nameof(Index))); } return(View(vehicle)); }
public async Task <IActionResult> Create(ProjectCreateViewModel createProject) { Project newProject = new Project() { Title = createProject.Title, Description = createProject.Description, ProjectStatusId = createProject.SelectedProjectStatus, ProjectTags = createProject.SelectedTags.Select(tag => new ProjectTag() { TagId = tag }).ToList() }; if (createProject.Photo != null) { var uniqueFileName = Guid.NewGuid().ToString() + Path.GetExtension(createProject.Photo.FileName); var pathName = Path.Combine(_hostingEnvironment.WebRootPath, "pics"); var fileNameWithPath = Path.Combine(pathName, uniqueFileName); using (var stream = new FileStream(fileNameWithPath, FileMode.Create)) { createProject.Photo.CopyTo(stream); } newProject.PhotoUrl = "/pics/" + uniqueFileName; } _projectDbContext.Projects.Add(newProject); await _projectDbContext.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create([Bind(Include = "AssignCourseId,DepartmentId,TeacherId,CreditToBeTaken,RemainingCredit,CourseId")] AssignCourse assignCourse) { if (ModelState.IsValid) { if (IsAssigned(assignCourse)) { FlashMessage.Danger("This Course is Already Assigned!"); return(RedirectToAction("Create")); } //assignCourse.Course.IsAssigned = true; db.AssignCourses.Add(assignCourse); await db.SaveChangesAsync(); FlashMessage.Confirmation("Successfully Assigned"); return(RedirectToAction("Create")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "DepartmentCode", assignCourse.DepartmentId); //ViewBag.TeacherId = new SelectList(db.Teachers, "TeacherId", "TeacherName", assignCourse.TeacherId); //ViewBag.CourseId = new SelectList(db.Courses, "CourseId", "CourseCode", assignCourse.CourseId); return(View(assignCourse)); }
public async Task <IActionResult> PutProject([FromRoute] int id, [FromBody] Lib.Models.Project project) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } 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> PutUserPermission([FromBody] UserPermission userPermission) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Entry(userPermission).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserPermissionExists(userPermission.UserProfileId, userPermission.ProjectId)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task DeleteAsync(int id) { Project existingProject = _context.Projects.FirstOrDefault(p => p.Id == id); if (existingProject != null) { _context.Projects.Remove(existingProject); await _context.SaveChangesAsync(); } }
public async Task DeleteAsync(int id) { Project projectToDelete = await _context.Projects.FindAsync(id); if (projectToDelete != null) { _context.Projects.Remove(projectToDelete); await _context.SaveChangesAsync(); } }
public async Task <IActionResult> Create([Bind("Id,ProductName,Price")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("ID,EmpKey,ProjKey,authorized_assignment")] ProjectAssignment projectAssignment) { if (!ModelState.IsValid) { return(View(projectAssignment)); } _context.Add(projectAssignment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("Id,Name")] Specification specification) { if (ModelState.IsValid) { _context.Add(specification); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(specification)); }
public async Task <IActionResult> Create([Bind("Id,Photo,Link")] Social social) { if (ModelState.IsValid) { _context.Add(social); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(social)); }
public async Task <IActionResult> Create([Bind("Id,Date,Discount,ExpiryDate,Client")] OfferHeader offerHeader) { if (ModelState.IsValid) { _context.Add(offerHeader); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(offerHeader)); }
public async Task <IActionResult> Create([Bind("Id,First_name,Last_name,Age,Email,Ssn")] Owner owner) { if (ModelState.IsValid) { _context.Add(owner); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(owner)); }
public async Task <IActionResult> Create([Bind("Id,ClientName")] Client client) { if (ModelState.IsValid) { _context.Add(client); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(client)); }
public async Task <IActionResult> Create([Bind("Id,Email,PhoneNumber")] Contact contact) { if (ModelState.IsValid) { _context.Add(contact); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(contact)); }
public async Task <IActionResult> Create([Bind("DailyTaskId,Description")] DailyTask dailyTask) { if (ModelState.IsValid) { _context.Add(dailyTask); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(dailyTask)); }
public async Task <IActionResult> Create([Bind("Id,Title,PublishedDate,Image")] News news) { if (ModelState.IsValid) { _context.Add(news); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(news)); }
public async Task <IActionResult> Create([Bind("Id,Name,Description,Estado")] Category category) { if (ModelState.IsValid) { _context.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("Id,Name,MarkaId")] Model model) { if (ModelState.IsValid) { _context.Add(model); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MarkaId"] = new SelectList(_context.Markas, "Id", "Name", model.MarkaId); return(View(model)); }
public async Task <ActionResult> Create(Department department) { if (ModelState.IsValid) { db.Departments.Add(department); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(department)); }
public async Task <IActionResult> Create([Bind("Id,Name,SubCategoryItemsId")] Marka marka) { if (ModelState.IsValid) { _context.Add(marka); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SubCategoryItemsId"] = new SelectList(_context.SubCategoryItems, "Id", "Name", marka.SubCategoryItemsId); return(View(marka)); }
public async Task <IActionResult> Create([Bind("Id,Name,Email,Building_type,Constructed_date,Stories,OwnerId")] Building building) { if (ModelState.IsValid) { _context.Add(building); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OwnerId"] = new SelectList(_context.Owners, "Id", "Email", building.OwnerId); return(View(building)); }
public async Task <IActionResult> Create([Bind("Id,Name,MainPhoto,Price,SalePercent,GuaranteeDate,GuaranteePrice,Condition,ShipDate,ShipPrice,TestDate,Specification,SubCategoryItemsId,IsInBasket")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SubCategoryItemsId"] = new SelectList(_context.SubCategoryItems, "Id", "Name", product.SubCategoryItemsId); return(View(product)); }
public async Task <IActionResult> Create([Bind("Id,Name,CategoryId")] SubCategory subCategory) { if (ModelState.IsValid) { _context.Add(subCategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", subCategory.CategoryId); return(View(subCategory)); }
public async Task <ActionResult> Create([Bind(Include = "DepartmentId,DepartmentName,DepartmentCode")] Department department) { if (ModelState.IsValid) { db.Departments.Add(department); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(department)); }
public async Task <IActionResult> Create([Bind("Id,Path,ProductId")] Photo photo) { if (ModelState.IsValid) { _context.Add(photo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "MainPhoto", photo.ProductId); return(View(photo)); }