示例#1
0
        public async Task UpdateMainInfo(UpdateMainInfoReq req, DatabaseContext context)
        {
            var currentUserData = this._currentUserService.GetCurrentUserData();

            var e = await context.Events
                    .Include(ee => ee.Vacancies)
                    .SingleAsync(ee => ee.Id == req.EventId && ee.Company.UserId == currentUserData.Id);

            var startTimeDistance = req.StartTime - e.StartTime;

            foreach (var vac in e.Vacancies)
            {
                vac.StartTime += startTimeDistance;
            }

            e.StartTime             = req.StartTime;
            e.EndTime               = req.EndTime;
            e.SegmentId             = req.SegmentId;
            e.CityId                = req.CityId;
            e.Address               = req.Address;
            e.EstimatedGuestsCount  = req.EstimatedGuestsCount;
            e.EstimatedAverageCheck = req.EstimatedAverageCheck;
            e.WithtDelivery         = req.WithDelivery;
            e.WithAccomodation      = req.WithAccomodation;

            if (e.IsPublished)
            {
                this.ThrowIfPublishingBroken(e);
            }
        }
示例#2
0
        public async Task UpdateMainInfo(UpdateMainInfoReq req, DatabaseContext context)
        {
            var currentUserData = this._currentUserService.GetCurrentUserData();

            var vac = context.Vacancies
                      .Single(v => v.Id == req.VacancyId && v.Event.Company.UserId == currentUserData.Id);

            vac.StartTime          = req.StartTime;
            vac.WorkingHours       = req.WorkingHours;
            vac.ExperienceOptionId = req.ExperienceOptionId;

            if (vac.IsPublished)
            {
                this.ThrowIfPublishingBroken(vac);
            }
        }
示例#3
0
        public async Task UpdateMainInfo(UpdateMainInfoReq req, DatabaseContext context)
        {
            var expertProfile = await context.ExpertProfiles
                                .Include(p => p.User)
                                .Include(p => p.ExpertProfileLanguages)
                                .Include(p => p.ExpertProfileSkills)
                                .SingleAsync(profile => profile.Id == req.ExpertProfileId);

            expertProfile.CityId             = req.CityId;
            expertProfile.ExperienceOptionId = req.ExperienceOptionId;

            var languagesIdsToAdd        = req.LanguagesIds.Where(id => expertProfile.ExpertProfileLanguages.All(l => l.LanguageId != id)).ToArray();
            var profileLanguagesToDelete = expertProfile.ExpertProfileLanguages.Where(lang => !req.LanguagesIds.Contains(lang.LanguageId)).ToArray();

            foreach (var profileLang in profileLanguagesToDelete)
            {
                expertProfile.ExpertProfileLanguages.Remove(profileLang);
            }

            foreach (var langId in languagesIdsToAdd)
            {
                expertProfile.ExpertProfileLanguages.Add(new ExpertProfileLanguage {
                    LanguageId = langId
                });
            }

            var skillsIdsToAdd        = req.SkillsIds.Where(id => expertProfile.ExpertProfileSkills.All(s => s.SkillId != id)).ToArray();
            var profileSkillsToDelete = expertProfile.ExpertProfileSkills.Where(s => !req.SkillsIds.Contains(s.SkillId)).ToArray();

            foreach (var skillId in skillsIdsToAdd)
            {
                expertProfile.ExpertProfileSkills.Add(new ExpertProfileSkill {
                    SkillId = skillId
                });
            }

            foreach (var profileSkill in profileSkillsToDelete)
            {
                expertProfile.ExpertProfileSkills.Remove(profileSkill);
            }

            if (expertProfile.IsPublished)
            {
                this.ThrowIfPublishingBroken(expertProfile);
            }
        }