コード例 #1
0
        public IActionResult ArtistCard()
        {
            if (User.HasClaim("Artist", "2"))
            {
            }
            else
            {
                return(View("JoiningArtist"));
            }
            var artist = aartistRepository.GetArtitByUserNmae(User.Identity.Name);

            if (artist != null)
            {
                var          citysWork = aartistRepository.GetCictyWorksByArtist(artist.Id);
                List <Citys> citys     = aartistRepository.GetCitysByIds(citysWork.Select(i => i.IdCity).ToList());

                var dayWork = aartistRepository.GetByIdArtist(artist.Id);

                ArtistSetings artistSetings = new ArtistSetings
                {
                    Price      = artist.Price,
                    TypeArtist = (ArtistType)artist.ArtistType,
                    TypeEvent  = (EventType)artist.EventType,
                    DaysWork   = dayWork,
                    Citys      = JsonConvert.SerializeObject(citys)
                };

                return(View(artistSetings));
            }
            return(View());
        }
コード例 #2
0
        public IActionResult Testsub(ArtistSetings artistSetings)
        {
            var idUser = aartistRepository.GetIdUserByUsurName(User.Identity.Name);

            //creat artist
            if (aartistRepository.IfArtisCreated(idUser) == false)
            {
                var citys = JsonConvert.DeserializeObject <List <Citys> >(artistSetings.Citys);

                var newIdArtit = aartistRepository.AddArtist(new Artist
                {
                    IdUser     = idUser,
                    ArtistType = (Enums.ArtistType)artistSetings.TypeArtist,

                    EventType = (Enums.EventType)artistSetings.TypeEvent,
                    Price     = artistSetings.Price,
                });

                artistSetings.DaysWork.IdArtit = newIdArtit;
                aartistRepository.AddDaysWork(artistSetings.DaysWork);
                aartistRepository.AddCictyWorks(citys, newIdArtit);
            }
            //edit artisi
            else
            {
                var artist = aartistRepository.GetArtitByIdUser(idUser);


                artist.ArtistType = (Enums.ArtistType)artistSetings.TypeArtist;

                artist.EventType = (Enums.EventType)artistSetings.TypeEvent;
                artist.Price     = artistSetings.Price;

                aartistRepository.EditArtist(artist);


                artistSetings.DaysWork.IdArtit = artist.Id;
                var dayWork = aartistRepository.GetByIdArtist(artist.Id);



                dayWork.Friday    = artistSetings.DaysWork.Friday;
                dayWork.Monday    = artistSetings.DaysWork.Monday;
                dayWork.Sunday    = artistSetings.DaysWork.Sunday;
                dayWork.Thursday  = artistSetings.DaysWork.Thursday;
                dayWork.Tuesday   = artistSetings.DaysWork.Tuesday;
                dayWork.Wednesday = artistSetings.DaysWork.Wednesday;


                aartistRepository.EditDaysWork(dayWork);


                var citys = JsonConvert.DeserializeObject <List <Citys> >(artistSetings.Citys);

                aartistRepository.DeleteAllCityWorkByIdArtist(artist.Id);
                aartistRepository.AddCictyWorks(citys, artist.Id);
            }
            return(View("ArtistCard", artistSetings));
        }