Esempio n. 1
0
        public async Task <bool> Add(WorkManagementCycle workManagementCycle)
        {
            _context.WorkManagementCycles.Add(workManagementCycle);
            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <IActionResult> Create([FromBody] WorkManagementCycle workManagementCycle)
        {
            if (workManagementCycle != null)
            {
                await _dataManager._workManagementCyclesRepository.Add(workManagementCycle);

                return(Ok());
            }
            else
            {
                return(BadRequest("Object is null"));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> OnGetAsync(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            WorkManagementCycle = await _requestSender.GetContetFromRequestAsyncAs <WorkManagementCycle>(
                await _requestSender.SendGetRequestAsync("https://localhost:44389/api/WorkManagementCycles/one?id=" + id));

            if (WorkManagementCycle == null)
            {
                return(NotFound());
            }
            return(Page());
        }
 public async Task <IActionResult> Update(WorkManagementCycle workManagementCycle)
 {
     if (workManagementCycle != null)
     {
         if (!(await _dataManager._workManagementCyclesRepository.Update(workManagementCycle)))
         {
             return(NotFound());
         }
         else
         {
             return(Ok());
         }
     }
     else
     {
         return(Problem("object is null"));
     }
 }
        public async Task <bool> SaveWorkManagementCycle(WorkManagementCycleEditViewModel cycleToSave)
        {
            if (cycleToSave != null)
            {
                var workManagementCycle = new WorkManagementCycle()
                {
                    Name          = cycleToSave.CycleName,
                    Semester      = cycleToSave.Semester,
                    NumberOfHours = cycleToSave.NumberOfHours,
                    GroupId       = Guid.Parse(cycleToSave.SelectedGroup)
                };
                var response = await _requestSender.SendPostRequestAsync("https://localhost:44389/api/WorkManagementCycles/create", workManagementCycle);

                return(true);
            }

            // Return false if customeredit == null or CustomerID is not a guid
            return(false);
        }
Esempio n. 6
0
        public async Task <bool> Update(WorkManagementCycle workManagementCycle)
        {
            _context.Attach(workManagementCycle).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(workManagementCycle.Id))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
            return(true);
        }
        public async Task <WorkManagementCycleEditViewModel> CreateWorkMangementCycle(WorkManagementCycle workManagementCycle)
        {
            var cycle = new WorkManagementCycleEditViewModel()
            {
                CycleName     = workManagementCycle.Name,
                NumberOfHours = workManagementCycle.NumberOfHours,
                Semester      = workManagementCycle.Semester,
                CycleId       = workManagementCycle.Id,
                Faculties     = await GetFaculties()
            };

            if (workManagementCycle.Group != null)
            {
                cycle.SelectedGroup = workManagementCycle.GroupId.ToString();
                if (workManagementCycle.Group.Department != null)
                {
                    cycle.Groups = await GetGroups(workManagementCycle.Group.DepartmentId);

                    cycle.SelectedDepartment = workManagementCycle.Group.DepartmentId.ToString();
                    if (workManagementCycle.Group.Department.FacultyId != null)
                    {
                        cycle.SelectedFaculty = workManagementCycle.Group.Department.FacultyId.ToString();
                        cycle.Departments     = await GetDepartments(workManagementCycle.Group.Department.FacultyId);
                    }
                }
            }
            return(cycle);
        }