Beispiel #1
0
        private void SetAccomplishment(ProfessionalExperience current, AccomplishmentViewModel acc)
        {
            Accomplishment existing = string.IsNullOrEmpty(acc.Id) ?
                                      new Accomplishment
            {
                IsRelevant = acc.IsRelevant,
                Summary    = "",
                Title      = acc.Title,
            } :
            _accomplishmentService.GetById(Guid.Parse(acc.Id));

            if (acc.IsDeleted)
            {
                _accomplishmentService.Delete(existing);
            }
            else
            {
                existing.IsRelevant = acc.IsRelevant;
                existing.Title      = acc.Title;

                if (string.IsNullOrEmpty(acc.Id))
                {
                    current.Accomplishments.Add(existing);
                }
            }
        }
 public IActionResult AccomplishmentEdit([FromForm] AccomplishmentViewModel model, int id)
 {
     if (model.Id == id && ModelState.IsValid)
     {
         model = _accomplishment.UpdateAccomplishmnet(model);
     }
     return(RedirectToAction("List"));
 }
 public IActionResult Put(AccomplishmentViewModel model)
 {
     if (ModelState.IsValid)
     {
         var result = _accomplishment.UpdateAccomplishmnet(model);
         return(Ok(result));
     }
     return(BadRequest());
 }
        public AccomplishmentViewModel UpdateAccomplishmnet(AccomplishmentViewModel model)
        {
            var accomplishment = _context.Accomplishments.FirstOrDefault(X => X.AccomplishmentId == model.Id);

            if (accomplishment != null)
            {
                accomplishment.Name = model.Name;
                accomplishment.DateOfAccomplishment = Convert.ToDateTime(model.DateOfAccomplishment);
                _context.SaveChanges();
            }

            return(model);
        }
Beispiel #5
0
        public IActionResult ValidUserRedirect(string Email, string Password)
        {
            var userquery = from u in _context.Users
                            where u.Email == Email
                            where u.Password == Password
                            select u;
            AccomplishmentViewModel LVM = new AccomplishmentViewModel();


            if (userquery.ToList().Count == 1)
            {
                foreach (var user in userquery)
                {
                    LVM.UserName            = user.Fname + " " + user.Lname;
                    LVM.UserEmail           = user.Email;
                    LVM.UserAccomplishments = user.Accomplishments;
                }
                return(RedirectToAction("Index", "Accomplishments", LVM));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #6
0
        public KonsultantCreationModel toViewModel(Konsultant source)
        {
            if (source == null)
            {
                return(new KonsultantCreationModel());
            }

            var result = new KonsultantCreationModel
            {
                Id           = source.Id.ToString(),
                Name         = source.Name,
                Surname      = source.Surname,
                Function     = source.Function,
                Availability = source.Availability.Date,
            };


            foreach (var comp in source.Competences)
            {
                var current = new CompetenceViewModel
                {
                    Id         = comp.CompetenceId.ToString(),
                    Name       = comp.Competence?.Name,
                    Rating     = (int)comp.Rating,
                    IsRelevant = comp.IsRelevant
                };

                result.Competences.Add(current);

                result.Competences = result.Competences.OrderByDescending(x => x.Rating).ToList();
            }

            foreach (var lang in source.Languages)
            {
                var current = new LanguageViewModel
                {
                    Id         = lang.LanguageId.ToString(),
                    Name       = lang.Language?.Name,
                    Fluency    = (int)lang.Fluency,
                    IsRelevant = lang.IsRelevant,
                };

                result.Languages.Add(current);
            }

            foreach (var edu in source.Educations)
            {
                var current = new EducationViewModel
                {
                    Id         = edu.EducationId.ToString(),
                    Name       = edu.Education?.Name,
                    StartDate  = edu.StartDate.Date,
                    EndDate    = edu.EndDate.Date,
                    IsRelevant = edu.IsRelevant
                };

                result.Educations.Add(current);
            }

            foreach (var cert in source.Certificates)
            {
                var current = new CertificateViewModel
                {
                    Id            = cert.CertificateId.ToString(),
                    Name          = cert.Certificate?.Name,
                    Obtension     = cert.Obtension,
                    EndOfValidity = cert.EndOfValidity,
                    IsRelevant    = cert.IsRelevant
                };

                result.Certificates.Add(current);
            }

            foreach (var exp in source.ProfessionalExperiences)
            {
                var curr = new ProfessionalExperienceViewModel
                {
                    Id         = exp.Id.ToString(),
                    Position   = exp.Position,
                    Summary    = exp.Summary,
                    Customer   = exp.Customer,
                    StartDate  = exp.StartDate.Date,
                    EndDate    = exp.EndDate.Date,
                    IsRelevant = exp.IsRelevant
                };

                foreach (var acc in exp.Accomplishments)
                {
                    var accomplished = new AccomplishmentViewModel
                    {
                        Id         = acc.Id.ToString(),
                        Title      = acc.Title,
                        IsRelevant = acc.IsRelevant
                    };
                    curr.Accomplishments.Add(accomplished);
                }
                ;

                foreach (var tech in exp.TechnicalEnvironments)
                {
                    var technical = new TechnicalEnvironmentViewModel
                    {
                        Id         = tech.Id.ToString(),
                        Name       = tech.Name,
                        IsRelevant = tech.IsRelevant
                    };

                    curr.TechnicalEnvironments.Add(technical);
                }
                ;

                result.ProfessionalExperiences.Add(curr);
            }

            foreach (var refer in source.ProfessionalReferences)
            {
                var current = new ProfessionalReferenceViewModel
                {
                    Id       = refer.Id.ToString(),
                    Name     = refer.Name,
                    Surname  = refer.Surname,
                    Function = refer.Function,
                    Mail     = refer.Contacts?.Mail,
                    Phone    = refer.Contacts?.Phone
                };

                result.ProfessionalReferences.Add(current);
            }

            return(result);
        }
 public IActionResult Index(AccomplishmentViewModel LVM)
 {
     return(View(LVM));
 }