Beispiel #1
0
        public ActionResult <ServiceConfirmationDto> CreateService([FromBody] ServiceCreationDto serviceDto, [FromHeader] string key)
        {
            try
            {
                if (!auth.AuthorizeUser(key))
                {
                    return(StatusCode(StatusCodes.Status401Unauthorized, "Authorization failed!"));
                }

                Service service = mapper.Map <Service>(serviceDto);
                serviceRepository.CreateService(service);
                serviceRepository.SaveChanges();

                logger.Log(LogLevel.Information, contextAccessor.HttpContext.TraceIdentifier, "", "New service created", null);

                string location = linkGenerator.GetPathByAction("GetServiceById", "Service", new { serviceId = service.ItemId });

                return(Created(location, mapper.Map <ServiceConfirmationDto>(service)));
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, contextAccessor.HttpContext.TraceIdentifier, "", "There is error while creating service", null);
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
        public void CreateServiceTest()
        {
            Service service = new Service();

            service.Name = "Otbelivanie";
            var resultMaster = _serviceRepository.CreateService(service);

            Assert.IsNotNull(resultMaster);
            Assert.IsTrue(service.Id != 0);
        }
Beispiel #3
0
        public void InsertService(IServiceRepository serviceRepository, IParticipantRepository participantRepository, CSService cSservice)
        {
            //Downloading the WSDL form WSDL URL taken form CC Register Service
            //string wsdlURL = null;
            //if (cSservice.Wsdl.EndsWith("?wsdl"))
            //    wsdlURL = cSservice.Wsdl.Replace("?wsdl", "?singlewsdl");
            //string wsdl = null;
            //using (var wc = new WebClient())
            //{
            //    using (var stream = wc.OpenRead(wsdlURL))
            //    {
            //        using (var sr = new StreamReader(stream))
            //        {
            //            wsdl = sr.ReadToEnd();
            //        }
            //    }
            //}

            var participantExist =
                participantRepository.GetParticipants().Any(x => x.Code == cSservice.ParticipantCode);

            if (participantExist)
            {
                var service = new CSService
                {
                    ParticipantCode = cSservice.ParticipantCode,
                    Code            = cSservice.Code,
                    Name            = cSservice.Name,
                    Wsdl            = cSservice.Wsdl
                };

                try
                {
                    serviceRepository.CreateService(service);
                }
                catch (Exception e)
                {
                    var nameLogerError = service.Name + "_ " + DateTime.Now;
                    using (var logger = LoggingFactory.GetNLogger(nameLogerError))
                    {
                        logger.Error(JsonConvert.SerializeObject(service), e);
                    }
                    throw new FaultException(e.Message);
                }
            }
            else
            {
                throw new FaultException("Не постои учесник со име: " + cSservice.ParticipantCode);
            }
        }
Beispiel #4
0
        public IActionResult Create(ServiceViewModel model)
        {
            if (ModelState.IsValid)
            {
                var service = _mapper.Map <ServiceViewModel, Service>(model);
                service.AddedBy = _admin.Fullname;

                _serviceRepository.CreateService(service);

                return(RedirectToAction("index"));
            }

            return(View(model));
        }
        async Task <bool> IServiceManager.Create(ServiceModel model, Guid userId)
        {
            Services service = new Services
            {
                Category     = model.Category,
                Subcategory  = model.Subcategory,
                CreatedBy    = userId,
                UpdatedBy    = userId,
                BillingUnit  = model.BillingUnit,
                MinimumUnit  = model.MinimumUnit,
                ServiceName  = model.ServiceName,
                Description  = model.Description,
                Price        = model.Price,
                ServiceImage = model.ServiceImage
            };
            await _serviceRepository.CreateService(service);

            return(true);
        }
Beispiel #6
0
        public Guid CreateService(ServiceRequestModel serviceRequestModel)
        {
            if (serviceRequestModel == null || string.IsNullOrWhiteSpace(serviceRequestModel.Name) || string.IsNullOrWhiteSpace(serviceRequestModel.Version))
            {
                return(Guid.Empty);
            }

            try
            {
                ServiceModel serviceModel = new ServiceModel()
                {
                    Name    = serviceRequestModel.Name,
                    Version = serviceRequestModel.Version
                };

                return(ServiceRepository.CreateService(serviceModel));
            }
            catch (Exception ex)
            {
                Logger.LogFile($"Error creating a Service: {ex.Message}");

                return(Guid.Empty);
            }
        }
 public string CreateService(ServiceViewModel model)
 {
     return(_ServiceRepository.CreateService(model));
 }
 public string CreateService(Service service)
 {
     return(_serviceRepository.CreateService(service));
 }
Beispiel #9
0
 public Service CreateServicer(Service service)
 {
     return(_serviceRepository.CreateService(service));
 }