public async Task <ActionResult> PostUserHardware(UserHardwareViewModel newuserHardware) { if (ModelState.IsValid) { var userHardware = new UserHardware(); userHardware.TimeStamp = DateTime.Now; var a = _context.Add(userHardware); await _context.SaveChangesAsync(); var UserHardwareId = _context.UserHardware.OrderBy(x => x.Id).LastOrDefault(); for (int i = 0; i < newuserHardware.disks.Count; i++) { var disks = new Disk(); foreach (var item in newuserHardware.disks) { disks.Name = item.name; disks.Type = item.type; disks.SerialNumber = item.serialNumber; disks.Title = item.title; disks.Spec = item.spec; disks.UserHardwareId = UserHardwareId.Id; } var b = _context.Add(disks); } for (int i = 0; i < newuserHardware.displays.Count; i++) { var displays = new Display(); foreach (var item in newuserHardware.displays) { displays.Name = item.name; displays.Type = item.type; displays.SerialNumber = item.serialNumber; displays.Manufacturer = item.manufacturer; displays.UserHardwareId = UserHardwareId.Id; } var c = _context.Add(displays); } for (int i = 0; i < newuserHardware.usbDevices.Count; i++) { var usbDevices = new UsbDevice(); foreach (var item in newuserHardware.usbDevices) { usbDevices.Name = item.name; usbDevices.Description = item.description; usbDevices.UserHardwareId = UserHardwareId.Id; } var d = _context.Add(usbDevices); } await _context.SaveChangesAsync(); return(CreatedAtAction("GetUserHardware", new { id = userHardware.Id }, newuserHardware)); } return(Ok()); }
public async Task <IActionResult> Create([Bind("Id,Business,Rate")] BusinessValues businessValues) { if (ModelState.IsValid) { _context.Add(businessValues); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(businessValues)); }
public async Task <IActionResult> Create([Bind("Id,Assignee,AssigneeRate")] Assignees assignees) { if (ModelState.IsValid) { _context.Add(assignees); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(assignees)); }
public async Task <IActionResult> Create([Bind("Id,CustomerName")] Clients clients) { if (ModelState.IsValid) { _context.Add(clients); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(clients)); }
public async Task <IActionResult> Create([Bind("Id,Status")] TasksStatus tasksStatus) { if (ModelState.IsValid) { _context.Add(tasksStatus); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tasksStatus)); }
public async Task <IActionResult> Create([Bind("Id,Type")] InvoiceType invoiceType) { if (ModelState.IsValid) { _context.Add(invoiceType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(invoiceType)); }
public async Task <IActionResult> Create([Bind("Id,Task,JobId,BusinessValuesId,TasksRate,TaskStatus,InvoiceTypeId")] Tasks tasks) { if (ModelState.IsValid) { _context.Add(tasks); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BusinessValuesId"] = new SelectList(_context.BusinessValues, "Id", "Business", tasks.BusinessValuesId); ViewData["JobId"] = new SelectList(_context.Jobs, "Id", "Id", tasks.JobId); ViewData["InvoiceTypeId"] = new SelectList(_context.InvoiceType, "Id", "Type"); return(View(tasks)); }
public async Task <IActionResult> Create([Bind("Id,DateCreated,Status,Description,TimeSpent,TaskId,JobId,ClientId,BusinessValueId,AssigneeId")] JobTasks jobTasks) { if (ModelState.IsValid) { _context.Add(jobTasks); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BusinessValueId"] = new SelectList(_context.BusinessValues, "Id", "Id", jobTasks.BusinessValueId); ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "Id", jobTasks.ClientId); ViewData["JobId"] = new SelectList(_context.Jobs, "Id", "Id", jobTasks.JobId); ViewData["TaskId"] = new SelectList(_context.Tasks, "Id", "Id", jobTasks.TaskId); ViewData["AssigneeId"] = new SelectList(_context.Users, "Id", "Id", jobTasks.AssigneeId); return(View(jobTasks)); }
public async Task <IActionResult> Create(Jobs jobs) { var clientname = _context.Clients.Where(x => x.Id == jobs.ClientId).FirstOrDefault(); if (ModelState.IsValid) { jobs.ClientName = clientname.Client; _context.Add(jobs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "Client", jobs.ClientId); return(View(jobs)); }
public async Task <IActionResult> Create(TimesheetViewModel model) { if (ModelState.IsValid) { var jobtask = new JobTasks(); jobtask.DateCreated = model.Date; jobtask.Status = model.Status; jobtask.Description = model.Description; jobtask.TimeSpent = model.TotalTime; jobtask.AssigneeId = model.AssigneeId; jobtask.BusinessValueId = model.BusinessValueId; jobtask.ClientId = model.ClientId; jobtask.JobId = model.JobId; jobtask.TaskId = model.TaskId; var dbjobtask = _context.Add(jobtask); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
public async Task <IActionResult> Setup(SetupViewModel SetupViewModel) { if (ModelState.IsValid) { var validation = _context.Jobs.SingleOrDefault(x => x.Job.ToString() == SetupViewModel.Job && x.ClientId == SetupViewModel.CustomerId); if (validation != null) { ModelState.AddModelError(string.Empty, "This project already exists."); var ClientList = _context.Clients.ToList(); var dropdownClientList = new List <SelectListItem>(); foreach (var clients in ClientList) { dropdownClientList.Add(new SelectListItem { Value = clients.Id.ToString(), Text = clients.Client.ToString() }); } ViewBag.CustomerNameList = dropdownClientList; var BusinessValuesList = _context.BusinessValues.ToList(); var dropdownBusinessValuesList = new List <SelectListItem>(); foreach (var values in BusinessValuesList) { dropdownBusinessValuesList.Add(new SelectListItem { Value = values.Business.ToString(), Text = values.Business.ToString() }); } ViewBag.BusinessValuesList = dropdownBusinessValuesList; return(View()); } else { Jobs jobs = new Jobs(); jobs.Job = SetupViewModel.Job; jobs.ClientId = SetupViewModel.CustomerId; var customer = _context.Clients.Where(x => x.Id == SetupViewModel.CustomerId).ToList(); foreach (var c in customer) { jobs.ClientName = c.Client; } _context.Add(jobs); await _context.SaveChangesAsync(); var project = _context.Jobs.Where(x => x.Job.ToString() == SetupViewModel.Job.ToString() && x.ClientId == SetupViewModel.CustomerId).ToList(); var busval = _context.BusinessValues.Where(x => x.Business.ToString() == SetupViewModel.BusinessValue.ToString()).ToList(); for (int i = 0; i < SetupViewModel.TaskName.Length; i++) { Tasks tasks = new Tasks(); tasks.Task = SetupViewModel.TaskName[i]; foreach (var p in project) { tasks.JobId = p.Id; } foreach (var b in busval) { tasks.BusinessValuesId = b.Id; } _context.Add(tasks); await _context.SaveChangesAsync(); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } return(View(SetupViewModel)); }