コード例 #1
0
        public DomainListContract<RatingTypeContract> SaveAllRatingTypes(DomainListContract<RatingTypeContract> contract)
        {
            try
            {
                using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString))
                {
                    var provider = new RatingTypeDal(context);
                    var process = new RatingTypeProcess(provider);
                    var service = new RatingTypeService(process);

                    var domainList = new RatingType().ConvertToDomain<RatingType, IEnumerable<RatingType>, RatingTypeContract>(contract);
                    var result = service.SaveAll(domainList);
                    var returnResult = new RatingType().ConvertToContract<RatingType, IEnumerable<RatingType>, RatingTypeContract>(result);
                    return returnResult;
                }

            }
            catch (Exception exception)
            {
                return HandleExceptionResponse<RatingTypeContract>(exception);
            }
        }
コード例 #2
0
        public RatingTypeContract CreateRatingType(RatingTypeContract contract)
        {
            try
            {
                using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString))
                {
                    var provider = new RatingTypeDal(context);
                    var process = new RatingTypeProcess(provider);
                    var service = new RatingTypeService(process);

                    var result = service.Create(new RatingType(contract));
                    var returnResult = new RatingType().ConvertToContract(result, new RatingTypeContract());
                    return returnResult;
                }

            }
            catch (Exception exception)
            {
                return HandleExceptionResponse<RatingType, RatingTypeContract>(exception);
            }
        }
コード例 #3
0
        public DomainStatusContract RemoveRatingType(int id)
        {
            try
            {
                using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString))
                {
                    var provider = new RatingTypeDal(context);
                    var process = new RatingTypeProcess(provider);
                    var service = new RatingTypeService(process);

                    var result = service.Remove(id);
                    return DomainStatus.ConvertToContract(result);
                }

            }
            catch (Exception exception)
            {
                return HandleExceptionResponse(exception);
            }
        }