Esempio n. 1
0
 public static SemesterUpdateableModel MapSemesterUpdateableModel(SemesterUpdate source)
 {
     return(new SemesterUpdateableModel
     {
         EndDate = source.EndDate,
         Id = source.Id,
         StartDate = source.StartDate
     });
 }
Esempio n. 2
0
        public async Task Delete(SemesterUpdate semester)
        {
            ValidationErrors = null;
            try
            {
                await _semesterService.Delete(semester.Id);

                Semesters.RowEditOptions.EditRowId = null;
                Semesters.RequestRefresh();
            }
            catch (ValidationException ve)
            {
                ValidationErrors = ve.Errors;
            }
        }
Esempio n. 3
0
        // Update specific item
        public SemesterUpdate UpdateSemester(SemesterUpdate updatedSemester)
        {
            var p = ds.Semesters.Find(updatedSemester.Id);

            if (p == null)
            {
                return(null);
            }
            else
            {
                // For the object fetched from the data store,
                // set its values to those provided
                // (the method ignores missing properties, and navigation properties)
                ds.Entry(p).CurrentValues.SetValues(updatedSemester);
                ds.SaveChanges();
                return(updatedSemester);
            }
        }
Esempio n. 4
0
        public async Task SaveEdit(SemesterUpdate semester)
        {
            ValidationErrors = null;
            try
            {
                await _semesterService.UpdateBasic(semester.Id, semester);

                Semesters.RowEditOptions.EditRowId = null;
                Semesters.RequestRefresh();
            }
            catch (ValidationPropertyException vpe)
            {
                ValidationErrors = vpe.ErrorsList;
            }
            catch (ValidationException ve)
            {
                ValidationErrors = ve.Errors;
            }
        }
Esempio n. 5
0
        public async Task<SemesterUpdate> UpdateBasic(int semesterId, SemesterUpdate model)
        {
            var semester = await context.Semester.FirstOrDefaultAsync(_ => _.Id == semesterId);
            if (semester == null)
                throw new ValidationException("Requested semester doesn't exist.");

            UpdateValues(semester, model);
            Validate(semester);

            await context.SaveChangesAsync();

            return new SemesterUpdate
            {
                Id = semester.Id,
                StartDate = semester.StartDate,
                EndDate = semester.EndDate,
                IsWinter = semester.IsWinter
            } ;
        }
Esempio n. 6
0
 public void Edit(SemesterUpdate semester)
 {
     Semesters.RowEditOptions.EditRowId = semester.Id;
 }
Esempio n. 7
0
 public void UpdateSemester(SemesterUpdate semester)
 {
     _utilityService.GetSemesterUpdates(semester);
 }
Esempio n. 8
0
        public static SemesterUpdateableModel MapSemesterUpdateableModel(this SemesterUpdateableModel dest, SemesterUpdate source)
        {
            dest.EndDate   = source.EndDate;
            dest.Id        = source.Id;
            dest.StartDate = source.StartDate;

            return(dest);
        }