Пример #1
0
        // GET: About
        public ActionResult Index()
        {
            YelCreativeEntities db = new YelCreativeEntities();
            AboutU         abt     = db.AboutUs.SingleOrDefault(x => x.Id_About == 1);
            AboutViewModel avm     = new AboutViewModel();

            avm.Id_About         = abt.Id_About;
            avm.Content_About    = abt.Content_About;
            avm.Update_Date      = abt.Update_Date;
            avm.Current_Position = abt.Current_Position;
            avm.Birthday         = abt.Birthday;
            avm.City             = abt.City;
            avm.Age    = abt.Age;
            avm.Degree = abt.Degree;

            if (Session["AdminID"] == null)
            {
                return(RedirectToAction("Auth"));
            }

            int id = Int32.Parse(Session["AdminId"].ToString());

            User usr = db.Users.SingleOrDefault(x => x.Id_User == id);

            ViewBag.AdminPhoto = usr.Image_Path;
            ViewBag.AdminName  = usr.Full_Name;

            return(View(avm));
        }
Пример #2
0
        public ActionResult DeleteService(int Id_Service)
        {
            YelCreativeEntities db      = new YelCreativeEntities();
            Service             service = db.Services.Find(Id_Service);

            db.Services.Remove(service);
            db.SaveChanges();

            var response = true;

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        public ActionResult Index(AboutViewModel model)
        {
            YelCreativeEntities db = new YelCreativeEntities();

            if (ModelState.IsValid == true)
            {
                AboutU ab = db.AboutUs.SingleOrDefault(x => x.Id_About == model.Id_About);
                ab.Id_About      = model.Id_About;
                ab.Content_About = model.Content_About;
                ab.Update_Date   = DateTime.Now;
                db.SaveChanges();
            }
            var response = true;

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        public ActionResult UpdateAboutMe(AboutViewModel model)
        {
            YelCreativeEntities db = new YelCreativeEntities();

            AboutU ab = db.AboutUs.SingleOrDefault(x => x.Id_About == model.Id_About);

            ab.Current_Position = model.Current_Position;
            ab.City             = model.City;
            ab.Age      = model.Age;
            ab.Birthday = model.Birthday;
            ab.Degree   = model.Degree;

            db.SaveChanges();

            var response = true;

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Пример #5
0
        public ActionResult EditService(int Id_Service)
        {
            YelCreativeEntities db    = new YelCreativeEntities();
            ServiceViewModel    model = new ServiceViewModel();

            List <Role> roleList = db.Roles.ToList();

            ViewBag.SelectRole = new SelectList(roleList, "Id_Role", "Role_Name");

            if (Id_Service > 0)
            {
                Service service = db.Services.SingleOrDefault(x => x.Id_Service == Id_Service);
                model.Id_Service      = service.Id_Service;
                model.Service_Name    = service.Service_Name;
                model.Content_Service = service.Content_Service;
            }

            return(PartialView("ServiceEditModal", model));
        }
Пример #6
0
        public ActionResult Index(ServiceViewModel model)
        {
            YelCreativeEntities db = new YelCreativeEntities();


            if (model.Id_Service > 0)
            {
                try
                {
                    Service service = db.Services.SingleOrDefault(x => x.Id_Service == model.Id_Service);

                    service.Id_Service      = model.Id_Service;
                    service.Service_Name    = model.Service_Name;
                    service.Content_Service = model.Content_Service;
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                        {
                            Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                        }
                    }
                }
            }
            else
            {
                Service service = new Service();
                service.Id_Service      = model.Id_Service;
                service.Service_Name    = model.Service_Name;
                service.Content_Service = model.Content_Service;

                db.Services.Add(service);
                db.SaveChanges();
            }
            var response = true;

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Пример #7
0
        // GET: Service
        public ActionResult Index()
        {
            YelCreativeEntities db          = new YelCreativeEntities();
            List <Service>      serviceList = db.Services.ToList();

            ViewBag.ServiceList = serviceList;

            if (Session["AdminId"] == null)
            {
                return(RedirectToAction("Auth"));
            }

            int id = Int32.Parse(Session["AdminId"].ToString());

            User usr = db.Users.SingleOrDefault(x => x.Id_User == id);

            ViewBag.AdminPhoto = usr.Image_Path;
            ViewBag.AdminName  = usr.Full_Name;

            return(View());
        }