Пример #1
0
        public int CreateList(ListCreateTO listCreate)
        {
            int createdListId = 0;

            using (var scope = new TransactionScope())
            {
                createdListId = _listRepository.Insert(listCreate.FilmIds, listCreate.Name, listCreate.UserId);

                addNewestListToCache(createdListId, false);
                scope.Complete();
            }

            return(createdListId);
        }
Пример #2
0
        public IHttpActionResult Post(ListCreateTO listCreate)
        {
            string[] words = { "kurwa", "skurwysyn", "chuj", "huj", "pierdol", "jebać", "jebac", "jebany" };

            foreach (var word in words)
            {
                if ((listCreate.Name.ToLower()).Contains(word))
                {
                    return(BadRequest(ListENUM.UNABLE_ADD_LIST.ToString()));
                }
            }

            string identityUserName = System.Web.HttpContext.Current.User.Identity.Name;

            var userId = _authService.GetUserId(identityUserName);

            if (userId == "")
            {
                logger.Log(LogLevel.Error, "Error during creating list: " + identityUserName + "doesn't exists!");
                return(BadRequest(UserENUM.USER_NOT_FOUND.ToString()));
            }

            listCreate.UserId = userId;

            foreach (var film in listCreate.FilmIds)
            {
                bool exists = _filmService.CheckIfFilmExists(film);
                if (!exists)
                {
                    return(BadRequest(FilmENUM.FILM_NOT_FOUND.ToString()));
                }
            }

            var createdListId = _listService.CreateList(listCreate);

            if (createdListId != 0)
            {
                return(StatusCode(HttpStatusCode.Created));
            }

            logger.Log(LogLevel.Error, "Unable to create list.\n");
            return(BadRequest(ListENUM.UNABLE_ADD_LIST.ToString()));
        }