Example #1
0
 public void Add(Movie movie, Guid[] locations)
 {
     foreach (Guid id in locations)
     {
         movie.Locations.Add(new LocationMovies {
             Movie = movie, LocationId = id
         });
     }
     _repo.Add(movie);
 }
 public void Add(Location location, Guid[] movies)
 {
     foreach (Guid id in movies)
     {
         location.Movies.Add(new LocationMovies {
             Location = location, MovieId = id
         });
     }
     _repo.Add(location);
 }
Example #3
0
 public Users Add(Users user)
 {
     if (string.IsNullOrEmpty(user.Surname))
     {
         throw new ArgumentException("Requires a surname.");
     }
     if (string.IsNullOrEmpty(user.Lastname))
     {
         throw new ArgumentException("Requires a lastname.");
     }
     return(repos.Add(user));
 }
Example #4
0
        public Books Add(Books entity)
        {
            if (string.IsNullOrEmpty(entity.Author))
            {
                throw new ArgumentException("Book needs an author.");
            }

            if (string.IsNullOrEmpty(entity.BookTitle))
            {
                throw new ArgumentException("Book needs a title.");
            }

            return(repos.Add(entity));
        }
        public ActionResult <Organization> PostOrganization([FromBody] Organization organization)
        {
            try
            {
                _log4net.Info("HttpPost Request Initiated for Id " + organization.Id);

                if (ModelState.IsValid)
                {
                    _log4net.Info("Model state is  valid for Id " + organization.Id);


                    _repository.Add(organization);


                    return(CreatedAtAction("GetOrganization", new { id = organization.Id }, organization));
                }
            }
            catch (Exception e)
            {
                _log4net.Error("Model state is not valid for id " + organization.Id + e.Message);
                return(NotFound());
            }
            return(BadRequest());
        }
Example #6
0
 public async Task <ActionResult> Test()
 {
     _repositories.Add();
     return(Json(new string[] { "value1", "value2" }));
 }