[Authorize(Roles = "Admin,Personnel")]  //Personnel
        public ActionResult Update(string Id, string Name, string Image, string Width, string Height, string Link, string Target,
                                   string Content, string Position, string Click, string Ord, string Active, string Image3, string Image4,
                                   string Lang, string Detail, string Title, string Description, string Keyword, string Image1, string Image2,
                                   string Image5, string Index, string Priority, string Tag, string NameEn, string ContentEn, string DetailEn)
        {
            SlideShow_Model data = new SlideShow_Model();//gọi model data

            data.Id          = Convert.ToInt32(Id);
            data.Name        = Name;
            data.Image       = Image;
            data.Width       = Convert.ToInt32(Width);
            data.Height      = Convert.ToInt32(Height);
            data.Link        = Link;
            data.Target      = Target;
            data.Content     = Content;
            data.Position    = Convert.ToInt16(Position);
            data.Click       = Convert.ToInt32(Click);
            data.Ord         = Convert.ToInt32(Ord);
            data.Active      = Convert.ToBoolean(Active);
            data.Lang        = Lang;
            data.Detail      = Detail;
            data.Title       = Title;
            data.Description = Description;
            data.Keyword     = Keyword;
            data.Image1      = Image1;
            data.Image2      = Image2;
            data.Image3      = Image3;
            data.Image4      = Image4;
            data.Image5      = Image5;
            data.Index       = Convert.ToInt32(Index);
            data.Priority    = Convert.ToInt32(Priority);
            data.Tag         = Tag;
            data.NameEn      = NameEn;
            data.ContentEn   = ContentEn;
            data.DetailEn    = DetailEn;

            if (connect_entity.SlideShows.FirstOrDefault
                    (x => x.Name == data.Name && x.Id != data.Id) == null) // kiểm tra không được trùng tên
            {
                Connect.Update(data);                                      //gọi service lưu
                Resurt = 1;
            }
            else
            {
                Resurt = 0;
            }
            return(Json(Resurt, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public void Create(SlideShow_Model model)
        {
            var data = Connect_Enttity.SlideShows.FirstOrDefault(x => x.Id == model.Id);

            if (data == null)
            {
                var entity = new SlideShow();

                entity.Name        = model.Name;
                entity.Image       = model.Image;
                entity.Width       = (int)(model.Width);
                entity.Height      = (int)(model.Height);
                entity.Link        = model.Link;
                entity.Target      = model.Target;
                entity.Content     = model.Content;
                entity.Position    = (short)(model.Position);
                entity.Click       = (int)(model.Click);
                entity.Ord         = (int)(model.Ord);
                entity.Active      = (bool)(model.Active);
                entity.Lang        = model.Lang;
                entity.Detail      = model.Detail;
                entity.Title       = model.Title;
                entity.Description = model.Description;
                entity.Keyword     = model.Keyword;
                entity.Image1      = model.Image1;
                entity.Image2      = model.Image2;
                entity.Image3      = model.Image3;
                entity.Image4      = model.Image4;
                entity.Image5      = model.Image5;
                entity.Index       = (int)(model.Index);
                entity.Priority    = (int)(model.Priority);
                entity.Tag         = model.Tag;
                entity.NameEn      = model.NameEn;
                entity.ContentEn   = model.ContentEn;
                entity.DetailEn    = model.DetailEn;

                Connect_Enttity.SlideShows.Add(entity);
                Connect_Enttity.SaveChanges();
                Dispose();
            }
        }
Ejemplo n.º 3
0
        public IList <SlideShow_Model> GetId(SlideShow_Model model)
        {
            IList <SlideShow_Model> result = new List <SlideShow_Model>();

            result = Connect_Enttity.SlideShows.Where(x => x.Id == model.Id).Select(x => new SlideShow_Model
            {
                Id          = x.Id,
                Name        = x.Name,
                Image       = x.Image,
                Width       = (int)(x.Width),
                Height      = (int)(x.Height),
                Link        = x.Link,
                Target      = x.Target,
                Content     = x.Content,
                Position    = (short)(x.Position),
                Click       = (int)(x.Click),
                Ord         = (int)(x.Ord),
                Active      = (bool)(x.Active),
                Lang        = x.Lang,
                Detail      = x.Detail,
                Title       = x.Title,
                Description = x.Description,
                Keyword     = x.Keyword,
                Image1      = x.Image1,
                Image2      = x.Image2,
                Image3      = x.Image3,
                Image4      = x.Image4,
                Image5      = x.Image5,
                Index       = (int)(x.Index),
                Priority    = (int)(x.Priority),
                Tag         = x.Tag,
                NameEn      = x.NameEn,
                ContentEn   = x.ContentEn,
                DetailEn    = x.DetailEn
            }).ToList();

            return(result);
        }
Ejemplo n.º 4
0
        public void Update(SlideShow_Model model)
        {
            var data = Connect_Enttity.SlideShows.FirstOrDefault(x => x.Id == model.Id);

            if (data != null)
            {
                data.Name        = model.Name;
                data.Image       = model.Image;
                data.Width       = (int)(model.Width);
                data.Height      = (int)(model.Height);
                data.Link        = model.Link;
                data.Target      = model.Target;
                data.Content     = model.Content;
                data.Position    = (short)(model.Position);
                data.Click       = (int)(model.Click);
                data.Ord         = (int)(model.Ord);
                data.Active      = (bool)(model.Active);
                data.Lang        = model.Lang;
                data.Detail      = model.Detail;
                data.Title       = model.Title;
                data.Description = model.Description;
                data.Keyword     = model.Keyword;
                data.Image1      = model.Image1;
                data.Image2      = model.Image2;
                data.Image3      = model.Image3;
                data.Image4      = model.Image4;
                data.Image5      = model.Image5;
                data.Index       = (int)(model.Index);
                data.Priority    = (int)(model.Priority);
                data.Tag         = model.Tag;
                data.NameEn      = model.NameEn;
                data.ContentEn   = model.ContentEn;
                data.DetailEn    = model.DetailEn;

                Connect_Enttity.SaveChanges();
                Dispose();
            }
        }
Ejemplo n.º 5
0
 public IEnumerable <SlideShow_Model> ReadID(SlideShow_Model model)
 {
     return(GetId(model));
 }