Exemple #1
0
        private static void EditIntern(EditInternBindingModel bm, Intern intern)
        {
            if (bm.Name != null)
            {
                intern.Name = bm.Name;
            }
            if (bm.CompanyId != null)
            {
                intern.CompanyId = bm.CompanyId.Value;
            }

            if (bm.PictureUrl != null)
            {
                intern.PictureUrl = bm.PictureUrl;
            }

            if (bm.Salary != null)
            {
                intern.Salary = bm.Salary.Value;
            }

            if (bm.StartDate != null)
            {
                intern.StartDate = bm.StartDate.Value;
            }

            if (bm.DaysOfInternship != null)
            {
                intern.DaysOfInternship = bm.DaysOfInternship.Value;
            }
        }
Exemple #2
0
        public IActionResult Edit(EditInternBindingModel bm, int id)
        {
            var intern = InternServices.GetInternById(id);

            if (!ModelState.IsValid)
            {
                var comapnies = CompanyServices.GetAllCompanies();

                var internDto = new EditInternDto()
                {
                    Intern    = intern,
                    Companies = comapnies
                };

                return(this.View(internDto));
            }

            EditIntern(bm, intern);

            this.InternServices.UpdateIntern(intern);
            var companies = this.CompanyServices.GetAllCompanies();

            intern = InternServices.GetInternById(id);

            var dto = new EditInternDto()
            {
                Intern    = intern,
                Companies = companies
            };

            this.ViewData["edit"] = "You have successfully edited this intern!";

            return(this.View(dto));
        }