Example #1
0
        public async Task <IActionResult> Create(Project_team project_team, int?clients, int?projects, int?employees)
        {
            GetSessions();

            if (ViewBag.Email == null)
            {
                return(ExpiredSession());
            }


            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(project_team);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index), new { clients, projects, employees }));
                }
                return(View(project_team));
            }
            catch (Exception e)
            {
                return(RedirectToAction(nameof(Error), new { message = e.Message }));
            }
        }
Example #2
0
        public async Task <IActionResult> PutProject_team([FromRoute] int id, [FromBody] Project_team project_team)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> PostProject_team([FromBody] Project_team project_team)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Project_team.Add(project_team);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProject_team", new { id = project_team.Id }, project_team));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Project_Id,Employee_Id,Start_Date,End_Date")] Project_team project_team, int?clients, int?projects, int?employees)
        {
            GetSessions();

            if (ViewBag.Email == null)
            {
                return(ExpiredSession());
            }


            try
            {
                if (id != project_team.Id)
                {
                    return(NotFound());
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Update(project_team);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException e)
                    {
                        if (!Project_teamExists(project_team.Id))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            return(RedirectToAction(nameof(Error), new { message = e.Message }));
                        }
                    }
                    return(RedirectToAction(nameof(Index), new { clients, projects, employees }));
                }
                return(View(project_team));
            }
            catch (Exception e)
            {
                return(RedirectToAction(nameof(Error), new { message = e.Message }));
            }
        }