Exemple #1
0
        public Response <Category> GetCatPerPerson(int idArtist)
        {
            try
            {
                IEnumerable <Category> allCategories;
                using (TTDBEntities db = new TTDBEntities())
                {
                    //allCategories = (from category in db.Categories
                    //                 join artist_category in db.Artists_Categories on category.IdCategory equals artist_category.IdCategory
                    //                 where artist_category.IdArtist == idPerson
                    //                 select new Category
                    //                 {
                    //                     IdCategory = category.IdCategory,
                    //                     CategoryName = category.CategoryName,
                    //                     Details = category.Details
                    //                 }).ToList()
                    //                .Select(x => new Category
                    //                {
                    //                    IdCategory = x.IdCategory,
                    //                    CategoryName = x.CategoryName,
                    //                    Details = x.Details,
                    //                });

                    allCategories = db.Artists_Categories.Where(ip => ip.IdArtist == idArtist).Include(a => a.Category).Select(x => x.Category) /*.Distinct()*/.ToList();
                }
                return(new Response <Category>(null, null, true, null, allCategories));
            }
            catch (Exception err)
            {
                return(new Response <Category>(err, null, false, null));
            }
        }
Exemple #2
0
        // GET: /Index

        public ActionResult Index(string keywords = "", string user = "")
        {
            var m = new HomeIndexModel();

            using (var db = new TTDBEntities())
            {
                IEnumerable <Item> result = db.Item;
                m.items = Item2ItemModel(SearchWithInput(keywords, result));
            }

            ViewBag.searchInput = keywords;
            /************************************************************************/
            /* for test                                                             */
            /* add login                                                            */
            /************************************************************************/
            if (user != "")
            {
                m.account = new AccountModel()
                {
                    screenName    = user,
                    isLandingPage = false,
                    isLogedIn     = true
                };
            }
            else
            {
                m.account = new AccountModel()
                {
                    isLandingPage = false
                };
            }

            return(View(m));
        }
        public Response <ImageDTO> GetURLPerPage(int page, int category)
        {
            try
            {
                List <ImageDTO> images = new List <ImageDTO>();
                using (TTDBEntities db = new TTDBEntities())
                {
                    List <Tattoos_By_Artist> queryImages;
                    if (category == 1)
                    {
                        queryImages = db.Tattoos_By_Artist.OrderByDescending(x => x.UploadImgDate).Skip(pagination * (page - 1)).Take(pagination).Include(x => x.Artist).ToList();
                    }
                    else
                    {
                        queryImages = db.Tattoos_By_Artist.Where(x => x.FK_TattooCategory == category).OrderByDescending(x => x.UploadImgDate).Skip(pagination * (page - 1)).Take(pagination).Include(x => x.Artist).ToList();
                    }

                    foreach (Tattoos_By_Artist image in queryImages)
                    {
                        ImageDTO aux = new ImageDTO(image.TattoosByArtistId, image.TattooName, image.TattooImgUrl, image.FK_IdArtist, image.FK_TattooCategory, image.TattooDate, image.UploadImgDate, image.TattooObservations, image.Artist.FullName);
                        images.Add(aux);
                    }
                }
                return(new Response <ImageDTO>(null, null, true, null, images));
            }
            catch (Exception err)
            {
                return(new Response <ImageDTO>(err, null, false, null));
            }
        }
 public Response <Category> Update(Category element)
 {
     try
     {
         Category updateCategory;
         using (TTDBEntities db = new TTDBEntities())
         {
             updateCategory = db.Categories.Find(element.IdCategory);
             if (element.CategoryName != null)
             {
                 updateCategory.CategoryName = element.CategoryName;
             }
             else if (element.Details != null)
             {
                 updateCategory.Details = element.Details;
             }
             db.Entry(updateCategory);
             db.SaveChanges();
         }
         return(new Response <Category>(null, updateCategory.IdCategory, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Category>(err, null, false, null));
     }
 }
Exemple #5
0
 public ItemGalleryModel(int skip = 0, int step = 20)
 {
     using (var data = new TTDBEntities())
     {
         Items = (from it in data.Item
                  orderby it.SellStartDate
                  select new GalleryItem()
         {
             Name = it.Name,
             ImgUrl = it.ItemPicture.FirstOrDefault(x => x.IsDefault).Picture.LargePictureAddress,
             Price = it.ListPrice.HasValue ? it.ListPrice.Value : 0.0
         }).Skip(skip).Take(step).ToList();
     }
 }
Exemple #6
0
        public JsonResult SignIn(string name, string pwd)
        {
            using (var db = new TTDBEntities())
            {
                var us = (from it in db.UserProfile
                          where it.UserName == name
                          select it).FirstOrDefault();

                var pd = (from itd in db.webpages_Membership
                          where itd.UserId == us.UserId
                          select itd.Password).FirstOrDefault();

                return(loginReturn(pd.Equals(pwd), us.UserName));
            }
        }
Exemple #7
0
 public Response <Artist> GetAll()
 {
     try
     {
         IEnumerable <Artist> allPeople;
         using (TTDBEntities db = new TTDBEntities())
         {
             allPeople = db.Artists.ToList();
         }
         return(new Response <Artist>(null, null, true, null, allPeople));
     }
     catch (Exception err)
     {
         return(new Response <Artist>(err, null, false, null));
     }
 }
 public Response <Category> GetAll()
 {
     try
     {
         IEnumerable <Category> allCategory;
         using (TTDBEntities db = new TTDBEntities())
         {
             allCategory = db.Categories.ToList();
         }
         return(new Response <Category>(null, null, true, null, allCategory));
     }
     catch (Exception err)
     {
         return(new Response <Category>(err, null, false, null));
     }
 }
 public Response <Category> Post(Category element)
 {
     try
     {
         using (TTDBEntities db = new TTDBEntities())
         {
             db.Categories.Add(element);
             db.SaveChanges();
         }
         return(new Response <Category>(null, element.IdCategory, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Category>(err, null, false, null));
     }
 }
Exemple #10
0
 public Response <Artists_Categories> Get(int idElement1, int idElement2 = 0)
 {
     try
     {
         Artists_Categories getPerson_Category;
         using (TTDBEntities db = new TTDBEntities())
         {
             getPerson_Category = db.Artists_Categories.Find(idElement1, idElement2);
         }
         return(new Response <Artists_Categories>(null, getPerson_Category.IdCategory, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Artists_Categories>(err, null, false, null));
     }
 }
Exemple #11
0
 public Response <Category> Get(int idElement1, int idElement2 = 0)
 {
     try
     {
         Category getCategory;
         using (TTDBEntities db = new TTDBEntities())
         {
             getCategory = db.Categories.Find(idElement1);
         }
         return(new Response <Category>(null, getCategory.IdCategory, true, getCategory));
     }
     catch (Exception err)
     {
         return(new Response <Category>(err, null, false, null));
     }
 }
Exemple #12
0
 public Response <Artist> Post(Artist element)
 {
     try
     {
         using (TTDBEntities db = new TTDBEntities())
         {
             db.Artists.Add(element);
             db.SaveChanges();
         }
         return(new Response <Artist>(null, element.IdArtist, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Artist>(err, null, false, null));
     }
 }
Exemple #13
0
 public Response <Artist> Get(int idElement1, int idElement2 = 0)
 {
     try
     {
         Artist getPerson;
         using (TTDBEntities db = new TTDBEntities())
         {
             getPerson = db.Artists.Find(idElement1);
         }
         return(new Response <Artist>(null, getPerson.IdArtist, true, getPerson));
     }
     catch (Exception err)
     {
         return(new Response <Artist>(err, null, false, null));
     }
 }
Exemple #14
0
 public Response <Category> Delete(int idElement1, int idElement2 = 0)
 {
     try
     {
         Category delCategory;
         using (TTDBEntities db = new TTDBEntities())
         {
             delCategory = db.Categories.Find(idElement1);
             db.Categories.Remove(delCategory);
             db.SaveChanges();
         }
         return(new Response <Category>(null, delCategory.IdCategory, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Category>(err, null, false, null));
     }
 }
Exemple #15
0
 public Response <Artist> Delete(int idElement1, int idElement2 = 0)
 {
     try
     {
         Artist delPerson;
         using (TTDBEntities db = new TTDBEntities())
         {
             delPerson = db.Artists.Find(idElement1);
             db.Artists.Remove(delPerson);
             db.SaveChanges();
         }
         return(new Response <Artist>(null, delPerson.IdArtist, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Artist>(err, null, false, null));
     }
 }
Exemple #16
0
        public JsonResult LoginWithFaceBook(string fbID) //, string fbEmail = "")
        {
            using (var db = new TTDBEntities())
            {
                /************************************************************************/
                /* find if login previously                                             */
                /************************************************************************/
                var result = from it in db.webpages_OAuthMembership
                             where it.Provider == @"facebook" && it.ProviderUserId == fbID
                             select it.UserId;

                if (result.Count() == 0)
                {
                    var ad = new webpages_OAuthMembership()
                    {
                        Provider       = @"facebook",
                        ProviderUserId = fbID
                    };

                    var au = new UserProfile()
                    {
                        UserName = fbID,
                        Email    = fbID
                    };

                    db.UserProfile.Add(au);
                    db.SaveChanges();

                    ad.UserId = ad.UserId;
                    db.webpages_OAuthMembership.Add(ad);
                    db.SaveChanges();

                    return(loginReturn(true, fbID));
                }
                else
                {
                    return(loginReturn(true, (from iter in db.UserProfile
                                              where iter.UserId == result.FirstOrDefault()
                                              select iter.UserName).FirstOrDefault()));
                }
            }

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Exemple #17
0
 public Response <Artist> Update(Artist element)
 {
     try
     {
         Artist updatePerson;
         using (TTDBEntities db = new TTDBEntities())
         {
             updatePerson = db.Artists.Find(element.IdArtist);
             if (element.FullName != null)
             {
                 updatePerson.FullName = element.FullName;
             }
             else if (element.BirthDate != null)
             {
                 updatePerson.BirthDate = element.BirthDate;
             }
             else if (element.StartDate != null)
             {
                 updatePerson.StartDate = element.StartDate;
             }
             else if (element.Email != null)
             {
                 updatePerson.Email = element.Email;
             }
             else if (element.PhoneNumber != null)
             {
                 updatePerson.PhoneNumber = element.PhoneNumber;
             }
             else if (element.Address != null)
             {
                 updatePerson.Address = element.Address;
             }
             db.Entry(updatePerson);
             db.SaveChanges();
         }
         return(new Response <Artist>(null, updatePerson.IdArtist, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Artist>(err, null, false, null));
     }
 }
Exemple #18
0
        public Response <Artist> GetPersonPerCat(int idCategory)
        {
            try
            {
                IEnumerable <Artist> allPeople;
                using (TTDBEntities db = new TTDBEntities())
                {
                    //allPeople = (from artist in db.Artists
                    //             join artist_category in db.Artists_Categories on artist.IdArtist equals artist_category.IdArtist
                    //             where artist_category.IdCategory == idCategory
                    //             select new
                    //             {
                    //                 IdArtist = artist.IdArtist,
                    //                 BirthDate = artist.BirthDate,
                    //                 FullName = artist.FullName,
                    //                 Address = artist.Address,
                    //                 Email = artist.Email,
                    //                 PhoneNumber = artist.PhoneNumber,
                    //                 StartDate = artist.StartDate
                    //             }).ToList()
                    //            .Select(x => new Artist
                    //            {
                    //                IdArtist = x.IdArtist,
                    //                BirthDate = x.BirthDate,
                    //                FullName = x.FullName,
                    //                Address = x.Address,
                    //                Email = x.Email,
                    //                PhoneNumber = x.PhoneNumber,
                    //                StartDate = x.StartDate
                    //            });

                    allPeople = db.Artists_Categories.Where(ac => ac.IdCategory == idCategory).Include(a => a.Artist).Select(x => x.Artist) /*.Distinct()*/.ToList();
                }
                return(new Response <Artist>(null, null, true, null, allPeople));
            }
            catch (Exception err)
            {
                return(new Response <Artist>(err, null, false, null));
            }
        }
Exemple #19
0
 public Response <Artists_Categories> Update(Artists_Categories element)
 {
     try
     {
         Artists_Categories updatePerson_Category;
         using (TTDBEntities db = new TTDBEntities())
         {
             updatePerson_Category = db.Artists_Categories.Find(element.IdArtist, element.IdCategory);
             if (element.Observation != null)
             {
                 updatePerson_Category.Observation = element.Observation;
             }
             db.Entry(updatePerson_Category);
             db.SaveChanges();
         }
         return(new Response <Artists_Categories>(null, updatePerson_Category.IdCategory, true, null));
     }
     catch (Exception err)
     {
         return(new Response <Artists_Categories>(err, null, false, null));
     }
 }
 public Response <ImageDTO> GetAll(int category)
 {
     try
     {
         int images;
         using (TTDBEntities db = new TTDBEntities())
         {
             if (category == 1)
             {
                 images = db.Tattoos_By_Artist.Count();
             }
             else
             {
                 images = db.Tattoos_By_Artist.Where(x => x.FK_TattooCategory == category).Count();
             }
         }
         return(new Response <ImageDTO>(null, images, true, null));
     }
     catch (Exception err)
     {
         return(new Response <ImageDTO>(err, null, false, null));
     }
 }
Exemple #21
0
        public JsonResult CreatMemberShip(string name, string pwd)
        {
            try
            {
                using (var db = new TTDBEntities())
                {
                    if ((from it in db.UserProfile
                         where it.UserName == name
                         select it).Count() > 0)
                    {
                        return(loginReturn(false, ""));
                    }

                    var nUser = new UserProfile()
                    {
                        UserName = name, Email = pwd
                    };
                    db.UserProfile.Add(nUser);
                    db.SaveChanges();
                    var nMem = new webpages_Membership()
                    {
                        Password = pwd, PasswordSalt = "", PasswordFailuresSinceLastSuccess = 0
                    };
                    nMem.UserId = nUser.UserId;
                    db.webpages_Membership.Add(nMem);
                    db.SaveChanges();

                    return(loginReturn(true, name));
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex);
                return(loginReturn(false, ""));
            }
        }
Exemple #22
0
        public ActionResult Search(string data)
        {
            dynamic searchData = JsonConvert.DeserializeObject(data);

            using (var db = new TTDBEntities())
            {
                IEnumerable <Item> result = db.Item;
                /************************************************************************/
                /* 1. Category                                                          */
                /************************************************************************/
                JArray catArrTmp = searchData.cats;
                var    catArr    = from it in catArrTmp
                                   select new string(it.ToString().ToCharArray());

                foreach (var cat in catArr)
                {
                    result = from it in result
                             where it.Category.Any(x => x.Category1.ToLower() == cat.ToLower())
                             select it;
                }

                /************************************************************************/
                /* 2. Color                                                             */
                /************************************************************************/
                JArray colArr_tmp = searchData.colors;
                var    colArr     = from it in colArr_tmp
                                    select new string(it.ToString().ToCharArray());

                foreach (var col in colArr)
                {
                    result = from it in result
                             where it.Color.Any(x => x.ColorName.ToLower() == col.ToLower())
                             select it;
                }

                /************************************************************************/
                /* 3. Size                                                              */
                /************************************************************************/
                JArray sizeArr_tmp = searchData.sizes;
                var    sizeArr     = from it in sizeArr_tmp
                                     select new string(it.ToString().ToCharArray());

                foreach (var size in sizeArr)
                {
                    result = from it in result
                             where it.ItemSize.Any(x => x.Size.SizeName.ToString().ToLower() == size.ToLower())
                             select it;
                }
                /************************************************************************/
                /* 4.1 find category                                                    */
                /************************************************************************/
                string input     = searchData.input;
                var    cat_candi = new CategoryModel();
                if (cat_candi.categories.Any(x => x.ToLower() == input.ToLower()))
                {
                    result = from it in result
                             where it.Category.Any(x => x.Category1.ToLower() == input.ToLower())
                             select it;
                }

                /************************************************************************/
                /* 4.2 find color                                                       */
                /************************************************************************/
                var col_candi = new ColorModel();
                if (col_candi.colors.Any(x => x.ToLower() == input.ToLower()))
                {
                    result = from it in result
                             where it.Color.Any(x => x.ColorName.ToLower() == input.ToLower())
                             select it;
                }
                return(PartialView("_IndexItemGallery",
                                   this.Item2ItemModel(result)));
            }
        }