public int AddUpdateTrainingSchedule(TrainingScheduleViewModel model, int OrganizationId) { TrainingSchedule schedule = Mapper.Map <TrainingScheduleViewModel, TrainingSchedule>(model); if (schedule.TrainingScheduleId == 0) { schedule.OrganizationId = OrganizationId; schedule.Completed = false; base.Insert(schedule); this._unitOfWork.Save(); } else { base.RepositoryContext.SP_DeleteALLTrainingScheduleRole(schedule.TrainingScheduleId, OrganizationId); base.RepositoryContext.SP_DeleteALLTrainingScheduleUser(schedule.TrainingScheduleId, OrganizationId); } if (model.UserList != null && model.UserList.Any()) { foreach (var data in model.UserList) { TrainingScheduleUser user = Mapper.Map <TrainingScheduleUserViewModel, TrainingScheduleUser>(data); user.TrainingScheduleId = schedule.TrainingScheduleId; user.OrganizationId = OrganizationId; this._ITrainingScheduleUserRepository.Add(user, 0, OrganizationId); } } if (model.RoleList != null && model.RoleList.Any()) { foreach (var data in model.RoleList) { TrainingScheduleRole role = Mapper.Map <TrainingScheduleRoleViewModel, TrainingScheduleRole>(data); role.TrainingScheduleId = schedule.TrainingScheduleId; role.OrganizationId = OrganizationId; this._ITrainingScheduleRoleRepository.Add(role, 0, OrganizationId); } } this._unitOfWork.Save(); return(schedule.TrainingScheduleId); }
public int AddUpdateTrainingSchedule(TrainingScheduleViewModel model) { return(this._ITrainingScheduleRepository.AddUpdateTrainingSchedule(model, base.OrganizationId)); }