Example #1
0
        public CreateMethodResponse Create(CreateMethodRequest request)
        {
            var response = new CreateMethodResponse();
            try
            {
                var method = request.MapTo<Method>();
                DataContext.Methods.Add(method);
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message = "Method item has been added successfully";
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return response;
        }
Example #2
0
        public CreateMethodResponse Create(CreateMethodRequest request)
        {
            var response = new CreateMethodResponse();

            try
            {
                var method = request.MapTo <Method>();
                DataContext.Methods.Add(method);
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message   = "Method item has been added successfully";
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return(response);
        }