Exemplo n.º 1
0
        public ActionResult Index(FormCollection input)
        {
            var IdArray             = input.GetValues("item.Id");
            var WordsArray          = input.GetValues("item.Words");
            var BackgroudImageArray = input.GetValues("item.BackgroudImage");
            var IndicateHeaderArray = input.GetValues("item.IndicateHeader");
            var IndicateWordsArray  = input.GetValues("item.IndicateWords");
            var OrderArray          = input.GetValues("item.Order");
            //var IssueArray = input.GetValues("item.Issue");
            var  ContentArray = input.GetValues("item.Content");
            long lanaguageId  = 1;

            for (int i = 0; i < IdArray.Count(); i++)
            {
                var Id     = Convert.ToInt64(IdArray[i]);
                var entity = _context.FindDetail <WebCarousel>(Id);
                lanaguageId           = entity.LanguageId;
                entity.Words          = WordsArray[i];
                entity.Content        = ContentArray[i];
                entity.BackgroudImage = BackgroudImageArray[i];
                entity.Order          = int.Parse(OrderArray[i]);
                entity.UpdatedDate    = DateTime.Now;
                entity.IndicateHeader = IndicateHeaderArray[i];
                entity.IndicateWords  = IndicateWordsArray[i];
                //entity.Issue = bool.Parse(IssueArray[i]);
            }
            _context.SaveChange();
            return(RedirectToAction <WebCarouselController>(d => d.Index(lanaguageId)));
        }
Exemplo n.º 2
0
        public ActionResult Index(FormCollection input)
        {
            var IdArray      = input.GetValues("item.Id");
            var NameArray    = input.GetValues("item.Name");
            var ImageArray   = input.GetValues("item.Image");
            var ContentArray = input.GetValues("item.Content");
            var AddressArray = input.GetValues("item.Address");
            var DateArray    = input.GetValues("item.Date");
            var DuringArray  = input.GetValues("item.During");

            long lanaguageId = 1;

            for (int i = 0; i < IdArray.Count(); i++)
            {
                var Id     = Convert.ToInt64(IdArray[i]);
                var entity = _context.FindDetail <WebEvent>(Id);
                entity.Name    = NameArray[i];
                entity.Address = AddressArray[i];
                entity.Date    = Convert.ToDateTime(DateArray[i]);
                entity.During  = DuringArray[i];
                var content = ContentArray[i];
                entity.Image       = _context.GetImage(content, "event");
                entity.Content     = content;
                entity.UpdatedDate = DateTime.Now;
            }
            _context.SaveChange();
            return(RedirectToAction <WebEventController>(d => d.Index(lanaguageId)));
        }
Exemplo n.º 3
0
        public ActionResult Index(FormCollection input)
        {
            var  IdArray               = input.GetValues("item.Id");
            var  NameArray             = input.GetValues("item.Name");
            var  ContentArray          = input.GetValues("item.Content");
            var  DepartmentIdArray     = input.GetValues("item.WebDepartmentId");
            var  ShortDescriptionArray = input.GetValues("item.ShortDescription");
            var  OrderArray            = input.GetValues("item.Order");
            long lanaguageId           = 1;
            var  LanguageIdArray       = input.GetValues("item.LanguageId");

            if (LanguageIdArray.Count() > 0)
            {
                lanaguageId = Convert.ToInt64(LanguageIdArray[0]);
            }

            for (int i = 0; i < IdArray.Count(); i++)
            {
                var Id     = Convert.ToInt64(IdArray[i]);
                var entity = _context.FindDetail <WebStory>(Id);
                entity.Name            = NameArray[i];
                entity.WebDepartmentId = Convert.ToInt64(DepartmentIdArray[i]);
                var content = ContentArray[i];
                entity.Image            = _context.GetImage(content, "staff");
                entity.Content          = content;
                entity.ShortDescription = ShortDescriptionArray[i];
                entity.UpdatedDate      = DateTime.Now;
                entity.Order            = int.Parse(OrderArray[i] == "" ? "5": OrderArray[i]);
            }
            _context.SaveChange();
            return(RedirectToAction <WebStoryController>(d => d.Index(lanaguageId)));
        }
Exemplo n.º 4
0
        public ActionResult Index(FormCollection input)
        {
            var IdArray               = input.GetValues("item.Id");
            var NameArray             = input.GetValues("item.Name");
            var ImageArray            = input.GetValues("item.Image");
            var ContentArray          = input.GetValues("item.Content");
            var DateArray             = input.GetValues("item.Date");
            var ShortDescriptionArray = input.GetValues("item.ShortDescription");

            var WebNewsTypeIdArray = input.GetValues("item.WebNewsTypeId");

            long lanaguageId     = 1;
            var  LanguageIdArray = input.GetValues("item.LanguageId");

            if (LanguageIdArray.Count() > 0)
            {
                lanaguageId = Convert.ToInt64(LanguageIdArray[0]);
            }

            for (int i = 0; i < IdArray.Count(); i++)
            {
                var Id     = Convert.ToInt64(IdArray[i]);
                var entity = _context.FindDetail <WebNews>(Id);
                entity.Name          = NameArray[i];
                entity.WebNewsTypeId = Convert.ToInt64(WebNewsTypeIdArray[i]);
                entity.Date          = Convert.ToDateTime(DateArray[i]);
                var content = ContentArray[i];
                entity.Image            = _context.GetImage(content, "news");
                entity.ShortDescription = ShortDescriptionArray[i];
                entity.Content          = content;
                entity.UpdatedDate      = DateTime.Now;
            }
            _context.SaveChange();
            return(RedirectToAction <WebNewsController>(d => d.Index(lanaguageId)));
        }
Exemplo n.º 5
0
        public ActionResult Upload(UploadFileViewModel uploadFiles)
        {
            for (int i = 0; i < uploadFiles.Files.Count; i++)
            {
                var file = uploadFiles.Files[i];
                if (file == null)
                {
                    continue;
                }
                var fileName = Path.GetFileName(file.FileName);
                if (string.IsNullOrEmpty(fileName))
                {
                    return(RedirectToAction("Index"));
                }
                var ext = fileName.Substring(fileName.IndexOf(".")).ToLower();
                if (ext == ".jpg" || ext == ".png" || ext == ".bmp")
                {
                    if (file.ContentLength > 1000000)
                    {
                        continue;
                    }
                }

                var newImage = new UserFile
                {
                    OperationDate = _db.GetNzTime(),
                    Operator      = _currentUser.User.Email,
                    FileType      = ext,
                    Category      = uploadFiles.Category,
                    Name          = fileName
                };
                _db.AddOneEntity(newImage);
                _db.SaveChange();
                if (ext == ".jpg" || ext == ".png" || ext == ".bmp")
                {
                    file.SaveAs(Server.MapPath("~/images/FileLibrary/" + newImage.Id + ext));
                }
                else
                {
                    file.SaveAs(Server.MapPath("~/images/FileLibrary/" + newImage.Name));
                }
            }
            return(RedirectToAction <UploadFilesController>(d => d.Index(uploadFiles.Category)));
        }
Exemplo n.º 6
0
        public ActionResult SaveAll(FormCollection input)
        {
            var  IdArray     = input.GetValues("item.Id");
            var  NameArray   = input.GetValues("item.Name");
            var  LinkArray   = input.GetValues("item.Link");
            var  OrderArray  = input.GetValues("item.Order");
            long lanaguageId = 1;

            for (int i = 0; i < IdArray.Count(); i++)
            {
                var Id     = Convert.ToInt64(IdArray[i]);
                var entity = _context.FindDetail <WebMenu>(Id);
                entity.Name = NameArray[i];
                entity.Link = LinkArray[i];
                int  order = 0;
                bool res   = int.TryParse(OrderArray[i], out order);
                entity.Order = order;
                lanaguageId  = entity.LanguageId;
            }
            _context.SaveChange();
            return(RedirectToAction <WebMenuController>(d => d.Index(lanaguageId)));
        }
Exemplo n.º 7
0
        public ActionResult Index(FormCollection input)
        {
            var IdArray   = input.GetValues("item.Id");
            var NameArray = input.GetValues("item.Name");

            long lanaguageId = 1;

            for (int i = 0; i < IdArray.Count(); i++)
            {
                var Id     = Convert.ToInt64(IdArray[i]);
                var entity = _context.FindDetail <WebJobType>(Id);
                entity.Name = NameArray[i];
                lanaguageId = entity.LanguageId;
            }
            _context.SaveChange();
            return(RedirectToAction <WebJobTypeController>(d => d.Index(lanaguageId)));
        }
Exemplo n.º 8
0
        public JsonResult _OperatorEdit(OperatorViewModel input)
        {
            _context.Get <ApplicationUser>(d => d.Id == input.Id).FirstOrDefault().UpdateDatetime = _context.GetNzTime();
            var opteratorRoles = _context.Get <IdentityUserRole>(d => d.UserId == input.Id).ToList();

            foreach (var item in opteratorRoles)
            {
                if (input.RolePosted != null)
                {
                    if (!input.RolePosted.ids.Any(d => d == item.RoleId))
                    {
                        var entity = _context.Get <IdentityUserRole>(d => d.RoleId == item.RoleId && d.UserId == input.Id).FirstOrDefault();
                        _context.GetTranscaiton().Entry(entity).State = EntityState.Deleted;
                    }
                }
                else
                {
                    var entity = _context.Get <IdentityUserRole>(d => d.RoleId == item.RoleId && d.UserId == input.Id).FirstOrDefault();
                    _context.GetTranscaiton().Entry(entity).State = EntityState.Deleted;
                }
            }
            _context.SaveChange();
            if (input.RolePosted != null)
            {
                foreach (var item in input.RolePosted.ids)
                {
                    if (!opteratorRoles.Any(d => d.RoleId == item))
                    {
                        _context.AddOneEntity <IdentityUserRole>(new IdentityUserRole {
                            UserId = input.Id, RoleId = item
                        });
                    }
                }
            }
            return(Json("1", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
        public ActionResult Add(WebLanguage input)
        {
            #region create new data
            var newLanguage = new WebLanguage {
                Name = input.Name
            };
            //menu
            foreach (var level1 in _context.Get <WebMenu>(d => d.LanguageId == 1 && d.ParentId == null).ToList())
            {
                var Newlevel1 = new WebMenu()
                {
                    Name = level1.Name, Content = level1.Content, Link = level1.Link, Order = level1.Order
                };
                foreach (var level2 in _context.Get <WebMenu>(d => d.LanguageId == 1 && d.ParentId == level1.Id).ToList())
                {
                    var Newlevel2 = new WebMenu()
                    {
                        Name = level2.Name, Content = level2.Content, Link = level2.Link, Order = level2.Order
                    };
                    foreach (var level3 in _context.Get <WebMenu>(d => d.LanguageId == 1 && d.ParentId == level2.Id).ToList())
                    {
                        Newlevel2.WebMenuChildren.Add(new WebMenu()
                        {
                            Name = level3.Name, Content = level3.Content, Link = level3.Link, Order = level3.Order
                        });
                    }
                    Newlevel1.WebMenuChildren.Add(Newlevel2);
                }
                newLanguage.WebMenus.Add(Newlevel1);
            }
            //college
            var college = _context.FindDetail <College>(1);
            _context.EntityCloneNew(college);
            newLanguage.College = college;

            //carousel
            foreach (var item in _context.Get <WebCarousel>(d => d.LanguageId == 1).ToList())
            {
                _context.EntityCloneNew(item);
                newLanguage.WebCarousels.Add(item);
            }
            //newsType
            foreach (var item in _context.Get <WebNewsType>(d => d.LanguageId == 1).Include(d => d.WebNews).ToList())
            {
                _context.EntityCloneNew(item);
                foreach (var news in item.WebNews)
                {
                    _context.EntityCloneNew(news);
                }
                newLanguage.WebNewsTypes.Add(item);
            }
            //events
            foreach (var item in _context.Get <WebEvent>(d => d.LanguageId == 1).ToList())
            {
                _context.EntityCloneNew(item);
                newLanguage.WebEvents.Add(item);
            }
            //JobType
            foreach (var item in _context.Get <WebJobType>(d => d.LanguageId == 1).ToList())
            {
                _context.EntityCloneNew(item);
                newLanguage.WebJobTypes.Add(item);
            }
            //Departments
            foreach (var item in _context.Get <WebDepartment>(d => d.LanguageId == 1).Include(d => d.WebStaff).Include(d => d.WebStories).Include(d => d.WebStudents).ToList())
            {
                _context.EntityCloneNew(item);
                foreach (var staff in item.WebStaff)
                {
                    _context.EntityCloneNew(staff);
                }
                foreach (var story in item.WebStories)
                {
                    _context.EntityCloneNew(story);
                }
                foreach (var student in item.WebStudents)
                {
                    _context.EntityCloneNew(student);
                }
                newLanguage.WebDepartment.Add(item);
            }
            //userful link
            foreach (var item in _context.Get <WebUsefulLink>(d => d.LanguageId == 1).ToList())
            {
                _context.EntityCloneNew(item);
                newLanguage.WebUsefulLinks.Add(item);
            }
            _context.AddOneEntity(newLanguage);
            #endregion
            #region update languageId
            //newsType
            var languageId = newLanguage.Id;
            foreach (var item in _context.Get <WebNewsType>(d => d.LanguageId == languageId).Include(d => d.WebNews).ToList())
            {
                foreach (var news in item.WebNews)
                {
                    news.LanguageId = languageId;
                }
            }
            //Departments
            foreach (var item in _context.Get <WebDepartment>(d => d.LanguageId == languageId).Include(d => d.WebStaff).Include(d => d.WebStories).Include(d => d.WebStudents).ToList())
            {
                foreach (var staff in item.WebStaff)
                {
                    staff.LanguageId = languageId;
                }
                foreach (var story in item.WebStories)
                {
                    story.LanguageId = languageId;
                }
                //foreach (var student in item.WebStudents)
                //{

                //}
            }
            _context.SaveChange();
            #endregion
            return(RedirectToAction <WebLanguageController>(d => d.Index()));
        }
Exemplo n.º 10
0
        public ActionResult UploadImage(FormCollection form)
        {
            HttpPostedFileBase file = Request.Files[0] as HttpPostedFileBase;
            var    imageName        = form.GetValues("imageName")[0];
            var    languageId       = form.GetValues("languageIdForImage")[0];
            string pic = "";

            if (file != null)
            {
                var fileName = Path.GetFileName(file.FileName);
                var ext      = fileName.Substring(fileName.IndexOf(".") + 1).ToLower();
                if (ext != "gif" && ext == "png" && ext == "jpg" && ext == "bmp")
                {
                    return(Json("Sorry, you can only upload gif,png,jpg or bmp file.", JsonRequestBehavior.AllowGet));
                }
                if (file.ContentLength > 200000)//200k
                {
                    return(Json("Sorry, your logo file size can not be bigger than 400k. Please upload proper size file.", JsonRequestBehavior.AllowGet));
                }
                using (System.Drawing.Image image = System.Drawing.Image.FromStream(file.InputStream, true, true))
                {
                    if (imageName == "Icon")
                    {
                        if (image.Width != 260 || image.Height != 130)
                        {
                            return(Json("Sorry, file dimensions is wrong.", JsonRequestBehavior.AllowGet));
                        }
                    }
                    pic = Guid.NewGuid().ToString() + "." + ext;
                    string path = System.IO.Path.Combine(Server.MapPath("/images/Main/"), pic);
                    file.SaveAs(path);
                    var college         = _context.FindDetail <College>(Convert.ToInt64(languageId));
                    var pathForDatabase = "/images/Main/" + pic;
                    if (imageName == "Icon")
                    {
                        college.Icon = pathForDatabase;
                    }
                    if (imageName == "Emphasis")
                    {
                        college.EmphasisImage = pathForDatabase;
                    }
                    if (imageName == "Introduction")
                    {
                        college.IntroductionImage = pathForDatabase;
                    }
                    if (imageName == "Dean")
                    {
                        college.DeanImage = pathForDatabase;
                    }
                    if (imageName == "Bar")
                    {
                        college.FootBarImage = pathForDatabase;
                    }
                    _context.SaveChange();
                    return(Json("done" + imageName + pathForDatabase, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json("Please select your file", JsonRequestBehavior.AllowGet));
            }
        }