public Response AddMovieToCinema([FromBody] ScreeingRequest request) { try { if (string.IsNullOrEmpty(request.Movie) || string.IsNullOrEmpty(request.Cinema) || string.IsNullOrEmpty(request.ShowDate) || string.IsNullOrEmpty(request.ShowTime)) { return(new Response { Status = "Fail", Message = "Movie,Cinema,ShowTime,ShowDate are mandatory to register" }); } _dALLayer.AddMovieToCinema(request); return(new Response { Status = "Success", Message = "Added SuccessFully." }); } catch (Exception) { throw; } }
void IDALLayer.AddMovieToCinema(ScreeingRequest request) { try { using (SqlConnection conn = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand("dbo.AddMovieToCinema", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@Cinema", SqlDbType.VarChar).Value = request.Cinema; command.Parameters.Add("@Movie", SqlDbType.VarChar).Value = request.Movie; command.Parameters.Add("@ShowDate", SqlDbType.NVarChar).Value = request.ShowDate; command.Parameters.Add("@ShowTime", SqlDbType.NVarChar).Value = request.ShowTime; command.Connection.Open(); command.ExecuteNonQuery(); } } catch (Exception) { throw; } }