Exemplo n.º 1
0
        public async Task <IActionResult> PutProjects([FromRoute] int id, [FromBody] Projects projects)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != projects.Id)
            {
                return(BadRequest());
            }

            _context.Entry(projects).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProjectsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Name,Description,Approved,ApprovedOn,ApprovedBy,StartDate,EndDate,CreatedOn,CreatedBy,ModifiedOn,ModifiedBy,Stage")] Projects projects)
        {
            if (ModelState.IsValid)
            {
                if (Request.Cookies["currentLoginUser"] != null)
                {
                    string userId = Request.Cookies["currentLoginUser"];
                    currentUserID = Convert.ToInt16(userId);
                }
                projects.CreatedBy = currentUserID;


                projects.ApprovedOn = DateTime.Today;
                projects.CreatedOn  = DateTime.Today;
                projects.ModifiedOn = DateTime.Today;
                projects.ApprovedBy = currentUserID;
                projects.ModifiedBy = currentUserID;
                projects.WorkflowId = 1;
                _context.Add(projects);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApprovedBy"] = new SelectList(_context.Users, "Uid", "UserName", projects.ApprovedBy);
            ViewData["CreatedBy"]  = new SelectList(_context.Users, "Uid", "UserName", projects.CreatedBy);
            ViewData["ModifiedBy"] = new SelectList(_context.Users, "Uid", "UserName", projects.ModifiedBy);
            return(View(projects));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var projects = await _context.Projects.FindAsync(id);

            _context.Projects.Remove(projects);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }