public static DetailArtist EditArtist(DetailArtist NewModel)
        {
            DetailArtist OldModel = DetailArtistDB.DetailFromId(NewModel.ArtistId);
            string       sql      = ArtistFunctions.ModifyArtistSring(NewModel, OldModel);

            DataAccess.SaveData(sql, NewModel);

            DetailArtist NewModelfromDB = new DetailArtist();

            NewModelfromDB = DetailArtistDB.DetailFromId(OldModel.ArtistId);

            return(NewModelfromDB);
        }
Esempio n. 2
0
        public ActionResult CreateArtist(Models.AddArtist model, HttpPostedFileBase file)
        {
            var dupa = model.Birthdate.ToString();
            var ad   = dupa;

            /*
             * "31.12.2020 00:00:00 +01:00"
             */

            model.File = file;
            if (ModelState.IsValid)
            {
                if (model.File != null)
                {
                    /*TODO zamienic tuple na OUT*/

                    byte[] Photo = null;
                    string Error = null;
                    //Tuple<byte[], string> Photo_error = ArtistFunctions.VerifyPhoto(model.File);
                    ArtistFunctions.VerifyPhoto(model.File, out Photo, out Error);

                    // if (Photo_error.Item1 == null)
                    if (Photo == null)
                    {
                        ModelState.AddModelError("", Error);
                        // ModelState.AddModelError("", Photo_error.Item2);
                        return(View());
                    }
                    model.Photo = Photo;
                    //model.Photo = Photo_error.Item1;
                }

                model.AddedBy = User.Identity.Name.ToString();

                int NewId = AddArtistDB.SaveArtisttoDB(model);
                if (NewId != 0)
                {
                    return(RedirectToAction("DetailsArtist", new { id = NewId }));
                }
                else
                {
                    /*TODO
                     * Jakiś error skrein do dodawania artysty*/
                }
            }
            return(View());
        }
Esempio n. 3
0
        public ActionResult ListArtist(int?Page, string sortOrder, List <DetailArtist> List)
        {
            int PageSize   = 10;
            int PageNumber = (Page ?? 1);

            if (List != null)
            {
                return(View(List.ToPagedList(PageNumber, PageSize)));
            }
            else
            {
                List = ListingArtistDB.SelectAll();

                ViewBag.LastNameSortParm  = String.IsNullOrEmpty(sortOrder) ? "LastNameDesc" : "LastName";
                ViewBag.DateSortParm      = sortOrder == "Date" ? "DateDesc" : "Date";
                ViewBag.FirstNameSortParm = sortOrder == "FirstName" ? "FirstNameDesc" : "FirstName";

                List = ArtistFunctions.OrderListArtist(List, sortOrder);

                return(View(List.ToPagedList(PageNumber, PageSize)));
            }
        }
Esempio n. 4
0
        public static List <DetailArtist> SearchArtist(string SearchString)
        {
            string sql = ArtistFunctions.SearchStringArtist(SearchString);

            return(DataAccess.LoadData <DetailArtist>(sql));
        }