예제 #1
0
        public ClassGroupModel CreateOrUpdate(ClassGroupModel model)
        {
            Logger.Debug($"{model}");

            if (model == null)
            {
                throw new System.ArgumentNullException("model");
            }

            ClassGroup group = null;

            if (model.Id == null || model.Id == System.Guid.Empty)
            {
                TrainingProgram.Models.TrainingProgram program = this.UnitOfWork.TrainingProgramRepository.CreateTrainingProgram(model.SemesterId, model.Name, model.Code, model.HighlightColor, model.LogoUrl, model.IsActive);

                group = this.UnitOfWork.ClassGroupRepository.CreateClassGroup(model.SemesterId, program.Id, model.Name, model.Code, model.HighlightColor, model.LogoUrl, model.IsActive);
            }
            else
            {
                group = this.UnitOfWork.ClassGroupRepository.UpdateClassGroup(model.Id, model.SemesterId, model.Name, model.Code, model.HighlightColor, model.LogoUrl, model.IsActive);
            }

            this.UnitOfWork.SaveChanges();

            ClassGroupModel groupModel = Mapper.Map <Models.ClassGroup, Models.ClassGroupModel>(group);

            return(groupModel);
        }
예제 #2
0
        public ClassGroupModel GetClassGroup(ClassGroupModel model)
        {
            Logger.Debug($"{model}");

            if (model == null || model.Id == null || model.Id == System.Guid.Empty)
            {
                throw new System.ArgumentNullException("model");
            }

            ClassGroup group = this.UnitOfWork.ClassGroupRepository.GetById(model.Id);

            ClassGroupModel groupModel = Mapper.Map <Models.ClassGroup, Models.ClassGroupModel>(group);

            return(groupModel);
        }