예제 #1
0
        public ServiceViewModel AddService(ServiceViewModel serviceVM)
        {
            var DuplicateService = _context.Services.Where(x => x.ServiceName == serviceVM.ServiceName).FirstOrDefault();

            if (DuplicateService != null)
            {
                throw new ArgumentException("Duplicate Service");
            }
            else
            {
                try
                {
                    _context.Add(new Models.Service()
                    {
                        ServiceName    = serviceVM.ServiceName,
                        ServiceContent = serviceVM.ServiceContent
                    });

                    _context.SaveChanges();

                    return(serviceVM);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            throw new NotImplementedException();
        }
예제 #2
0
        public PortfolioViewModel PostPortfolio(PortfolioViewModel portfolioVM)
        {
            var DuplicatePorfo = _context.Portfolios.Where(x => x.PortfoName == portfolioVM.PortfoName).FirstOrDefault();

            if (DuplicatePorfo != null)
            {
                throw new ArgumentException("Duplicate Portfolio");
            }
            else
            {
                try
                {
                    _context.Portfolios.Add(new Portfolio()
                    {
                        PortfoName = portfolioVM.PortfoName,
                        IdCategory = portfolioVM.IdCategory,
                        ImageByte  = portfolioVM.ImageByte,
                        ImagePath  = portfolioVM.ImagePath,
                        ImageTitle = portfolioVM.ImageTitle
                    });

                    _context.SaveChanges();

                    return(portfolioVM);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
예제 #3
0
        public SkillViewModel UpdateSkill(SkillViewModel skillVM)
        {
            var data = _context.Skills.Where(x => x.IdSkill == skillVM.IdSkill).FirstOrDefault();

            if (data != null)
            {
                data.SkillName  = skillVM.SkillName;
                data.SkillValue = skillVM.SkillValue;

                _context.SaveChanges();
            }
            return(null);
        }
예제 #4
0
        public ContactViewModel UpdateContact(ContactViewModel contactVM)
        {
            try
            {
                var data = _context.Contacts.Where(x => x.IdContact == contactVM.IdContact).FirstOrDefault();

                if (data != null)
                {
                    data.Address = contactVM.Address;
                    data.Phone   = contactVM.Phone;
                    data.Email   = contactVM.Email;

                    _context.SaveChanges();
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
        public AboutViewModel Update(AboutViewModel aboutVM)
        {
            var data = _context.Abouts.Where(x => x.IdAbout == aboutVM.IdAbout).FirstOrDefault();

            if (data != null)
            {
                data.AboutMe         = aboutVM.AboutMe;
                data.Age             = aboutVM.Age;
                data.City            = aboutVM.City;
                data.Country         = aboutVM.Country;
                data.Degree          = aboutVM.Degree;
                data.CurrentPosition = aboutVM.CurrentPosition;
                data.Birthday        = aboutVM.Birthday;

                _context.SaveChanges();
            }
            return(null);
        }