Пример #1
0
        static void Main(string[] args)
        {
            var    placeAddress = new PlaceAddress("Poland", "Warsaw", "Obywatelska", "5", "02-409");
            IPlace place        = new Place();

            place.PlaceId;
            DateTime     dateTime     = DateTime.Now;
            PlacePicture placePicture = new PlacePicture(place, dateTime);
        }
Пример #2
0
 public static ACL GetACL(ISession session, PlacePicture instance, Type type) { return new ManagedPlacePicture(session, instance).GetACL(type); }
Пример #3
0
 public static string GetObjectName(PlacePicture instance, int id) { return string.Format("{0} Pictures: {1}", instance.Place.Name, instance.Name); }
Пример #4
0
 public static int GetOwnerId(PlacePicture instance, int id) { return instance.Place.Account.Id; }
Пример #5
0
        public ActionResult AddPlace(AddPlaceViewModel apvm, HttpPostedFileBase AddPicture)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    int  countryId = Convert.ToInt32(apvm.CountryId);
                    int  cityId    = Convert.ToInt32(apvm.CityId);
                    bool result;
                    result = pl.CheckPlaceExist(apvm.PlaceName, countryId, cityId);
                    if (result == false)
                    {
                        int placeTypeId = Convert.ToInt32(apvm.PlaceTypeId);


                        Place place = new Place();
                        place.PlaceName   = apvm.PlaceName;
                        place.PlaceTypeId = Convert.ToInt32(apvm.PlaceTypeId);

                        place.CountryId    = Convert.ToInt32(apvm.CountryId);
                        place.CityId       = Convert.ToInt32(apvm.CityId);
                        place.PlaceAddress = apvm.PlaceAddress;
                        if (apvm.PlaceDetail == null)
                        {
                            place.PlaceDetail = "Not Given yet.";
                        }
                        else
                        {
                            place.PlaceDetail = apvm.PlaceDetail;
                        }

                        place.PlaceAdminsPermit          = true;
                        place.PlaceDateOfAccountCreation = DateTime.Now;
                        place.PlaceFavourite             = 0;
                        PlacePicture pp = new PlacePicture();
                        entity.Places.Add(place);

                        if (entity.SaveChanges() > 0)
                        {
                            var p = (from c in entity.Places where c.PlaceName == apvm.PlaceName && c.CountryId == apvm.CountryId && c.CityId == apvm.CityId select new { c.PlaceId, c.CountryId, c.CityId }).FirstOrDefault();
                            if (AddPicture != null)
                            {
                                PlaceAlbum pa = new PlaceAlbum();
                                pa.PlaceAlbumName           = "Profile Picture";
                                pa.PlaceId                  = p.PlaceId;
                                pa.AlbumTypeId              = 1;
                                pa.CityId                   = p.CityId;
                                pa.CountryId                = p.CountryId;
                                pa.PlaceAlbumAdminPermit    = true;
                                pa.PlaceAlbumPivacy         = true;
                                pa.PlaceAlbumDateOfCreation = DateTime.Now;
                                entity.PlaceAlbums.Add(pa);
                                entity.SaveChanges();
                                pp.PlacePictureData = new byte[AddPicture.ContentLength];
                                AddPicture.InputStream.Read(pp.PlacePictureData, 0, AddPicture.ContentLength);
                                pp.PlaceId = p.PlaceId;
                                var albumId = (from c in entity.PlaceAlbums where c.PlaceId == p.PlaceId && c.AlbumTypeId == 1 select c.PlaceAlbumId).Single();
                                int AlbumId = Convert.ToInt32(albumId);
                                pp.PlaceAlbumId            = AlbumId;
                                pp.AlbumTypeId             = 1;
                                pp.PlacePictureAdminPermit = true;
                                pp.CountryId = p.CountryId;
                                pp.CityId    = p.CityId;

                                pp.PlacePicturePrivacy     = true;
                                pp.PlacePictureDateOfAdded = DateTime.Now;
                                entity.PlacePictures.Add(pp);
                                if (entity.SaveChanges() > 0)
                                {
                                    Place d         = (from c in entity.Places where c.PlaceId == p.PlaceId select c).FirstOrDefault();
                                    int   pictureId = (from c in entity.PlacePictures
                                                       where c.PlaceId == p.PlaceId && c.AlbumTypeId == 1
                                                       orderby c.PlacePictureId descending
                                                       select c.PlacePictureId).First();
                                    d.PlaceProfilePicId = pictureId;
                                    entity.SaveChanges();
                                }
                            }
                            ModelState.Clear();
                            TempData["Success"] = "Added Successfully";
                        }
                        else
                        {
                            TempData["Success"] = "Problem occured";
                        }
                    }
                    else
                    {
                        TempData["Success"] = "Duplicacy found";
                    }
                    AddPlaceViewModel apvm1 = new AddPlaceViewModel();
                    apvm1.CountryList = new SelectList(entity.Countries, "CountryId", "CountryName");



                    apvm1.PlaceTypeList = new SelectList(entity.PlaceTypes, "PlaceTypeId", "PlaceTypeName");



                    return(View(apvm1));
                }
                catch (Exception ex)
                {
                    return(View("Error", new HandleErrorInfo(ex, "Place", "AddPlace")));
                }
            }
            else
            {
                AddPlaceViewModel apvm1 = new AddPlaceViewModel();
                apvm1.CountryList = new SelectList(entity.Countries, "CountryId", "CountryName");



                apvm1.PlaceTypeList = new SelectList(entity.PlaceTypes, "PlaceTypeId", "PlaceTypeName");



                return(View(apvm1));
            }
        }
Пример #6
0
        public ActionResult AddProfilePic(int PlaceId, int albumTypeId, HttpPostedFileBase AddPicture)
        {
            PlaceLogic   pl = new PlaceLogic();
            PlacePicture pp = new PlacePicture();

            if ((string)Session["userCode"] == "admin")
            {
                try
                {
                    var p = (from c in entity.Places where c.PlaceId == PlaceId select new { c.CountryId, c.CityId }).FirstOrDefault();

                    bool  result = pl.CheckPlaceIdAlbumTypeIdInPictureAlbum(PlaceId, albumTypeId);
                    Place place  = (from c in entity.Places where c.PlaceId == PlaceId select c).FirstOrDefault();
                    if (result == true)
                    {
                        var albumId = (from c in entity.PlaceAlbums where c.PlaceId == PlaceId && c.AlbumTypeId == albumTypeId select c.PlaceAlbumId).Single();
                        int AlbumId = Convert.ToInt32(albumId);
                        if (AddPicture != null)
                        {
                            pp.PlacePictureData = new byte[AddPicture.ContentLength];
                            AddPicture.InputStream.Read(pp.PlacePictureData, 0, AddPicture.ContentLength);
                        }
                        else
                        {
                            TempData["message"] = "no picture has been selected";
                            return(RedirectToAction("PlaceDetail", new { PlaceId = PlaceId }));
                        }
                        pp.PlaceId                 = PlaceId;
                        pp.PlaceAlbumId            = AlbumId;
                        pp.AlbumTypeId             = albumTypeId;
                        pp.PlacePictureAdminPermit = true;
                        pp.CountryId               = p.CountryId;
                        pp.CityId = p.CityId;
                        pp.PlacePictureAdminPermit = true;
                        pp.PlacePicturePrivacy     = true;
                        pp.PlacePictureDateOfAdded = DateTime.Now;
                        entity.PlacePictures.Add(pp);
                        if (entity.SaveChanges() > 0)
                        {
                            int pictureId = (from c in entity.PlacePictures
                                             where c.PlaceId == PlaceId && c.AlbumTypeId == albumTypeId
                                             orderby c.PlacePictureId descending
                                             select c.PlacePictureId).First();
                            place.PlaceProfilePicId = pictureId;
                            entity.SaveChanges();
                            TempData["PlaceProPic"] = "Profile Picture added";


                            return(RedirectToAction("SearchPlaceDetail", "Place", new { PlaceId = PlaceId }));
                        }
                        else
                        {
                            TempData["PlaceProPic"] = "not added";

                            return(RedirectToAction("SearchPlaceDetail", "Place", new { PlaceId = PlaceId }));
                        }
                    }
                    else
                    {
                        if (AddPicture != null)
                        {
                            pp.PlacePictureData = new byte[AddPicture.ContentLength];
                            AddPicture.InputStream.Read(pp.PlacePictureData, 0, AddPicture.ContentLength);
                        }
                        else
                        {
                            TempData["PlaceProPic"] = "no picture has been selected";

                            return(RedirectToAction("SearchPlaceDetail", "Place", new { PlaceId = PlaceId }));
                        }

                        PlaceAlbum pa = new PlaceAlbum();
                        pa.PlaceAlbumName           = "Profile Picture";
                        pa.PlaceId                  = PlaceId;
                        pa.AlbumTypeId              = albumTypeId;
                        pa.CityId                   = p.CityId;
                        pa.CountryId                = p.CountryId;
                        pa.PlaceAlbumAdminPermit    = true;
                        pa.PlaceAlbumPivacy         = true;
                        pa.PlaceAlbumDateOfCreation = DateTime.Now;
                        entity.PlaceAlbums.Add(pa);
                        entity.SaveChanges();
                        pp.PlaceId = PlaceId;
                        var albumId = (from c in entity.PlaceAlbums where c.PlaceId == PlaceId && c.AlbumTypeId == albumTypeId select c.PlaceAlbumId).Single();
                        int AlbumId = Convert.ToInt32(albumId);
                        pp.PlaceAlbumId            = AlbumId;
                        pp.AlbumTypeId             = albumTypeId;
                        pp.PlacePictureAdminPermit = true;
                        pp.CountryId = p.CountryId;
                        pp.CityId    = p.CityId;

                        pp.PlacePicturePrivacy     = true;
                        pp.PlacePictureDateOfAdded = DateTime.Now;
                        entity.PlacePictures.Add(pp);
                        if (entity.SaveChanges() > 0)
                        {
                            int pictureId = (from c in entity.PlacePictures
                                             where c.PlaceId == PlaceId && c.AlbumTypeId == albumTypeId
                                             orderby c.PlacePictureId descending
                                             select c.PlacePictureId).First();
                            place.PlaceProfilePicId = pictureId;
                            entity.SaveChanges();

                            TempData["PlaceProPic"] = "Picture Added";

                            return(RedirectToAction("SearchPlaceDetail", "Place", new { PlaceId = PlaceId }));
                        }
                        else
                        {
                            TempData["PlaceProPic"] = "No added";

                            return(RedirectToAction("SearchPlaceDetail", "Place", new { PlaceId = PlaceId }));
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(View("Error", new HandleErrorInfo(ex, "Place", "AddProfilePic")));
                }
            }
            else
            {
                Session["message"] = "please log in First";
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #7
0
 public static ACL GetACL(ISession session, PlacePicture instance, Type type)
 {
     return(new ManagedPlacePicture(session, instance).GetACL(type));
 }
Пример #8
0
 public static string GetObjectName(PlacePicture instance, int id)
 {
     return(string.Format("{0} Pictures: {1}", instance.Place.Name, instance.Name));
 }
Пример #9
0
 public static int GetOwnerId(PlacePicture instance, int id)
 {
     return(instance.Place.Account.Id);
 }