Ejemplo n.º 1
0
		private void detach_UserBanners(UserBanner entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
Ejemplo n.º 2
0
        public ActionResult SaveBanner(UserBanner banner)
        {
            if (!IsAuthentificated)
            {
                return RedirectToAction("Register");
            }

            UserBanner ban = null;

            if (banner.Id <= 0)
            {
                banner.User = CurrentUser;
                CurrentUser.UserBanners.Add(banner);
                ban = banner;
            }
            else
            {
                ban = CurrentUser.UserBanners.FirstOrDefault(b => b.Id == banner.Id);
                if (ban == null)
                {
                    return RedirectToAction("Banners");
                }
                ban.Color = banner.Color;
                ban.Size = banner.Size;
                ban.ImageUrl = banner.ImageUrl;
                ban.BannerPosition = banner.BannerPosition;
                ban.CustomBanner = banner.CustomBanner;
                ban.Task = banner.Task;
                ban.Position = banner.Position;
                ban.Href = banner.Href;
                ban.Text = banner.Text;
                ban.Height = banner.Height;
                ban.Enabled = banner.Enabled;
            }

            // Сохраняем файл
            var image = Request.Files["bg"];
            if (image != null && image.ContentLength > 0 && image.ContentType.Contains("image"))
            {
                var filename = String.Format("{0}-{1}{2}", Path.GetFileNameWithoutExtension(image.FileName),
                                             new Random(System.Environment.TickCount).Next(Int32.MaxValue), Path.GetExtension(image.FileName));
                FileUtils.SavePostedFile(image,"banner",filename);
                ban.ImageUrl = String.Format("banner/{0}", filename);
            }

            UsersRepository.SubmitChanges();

            // Возвращаем обратно на страницу редактирования
            return RedirectToAction("Banners");
        }
Ejemplo n.º 3
0
		private void attach_UserBanners(UserBanner entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}