示例#1
0
        public IActionResult ServiceInfo(int serviceId)
        {
            #region ServiceData
            int langId = 1;

            if (Request.Cookies["LangKey"] != null)
            {
                langId = Convert.ToInt32(Request.Cookies["LangKey"]);
            }
            OurServicesDTO prms    = new OurServicesDTO();
            ServiceInfo    service = new ServiceInfo();
            Task           tsk1    = Task.Factory.StartNew(() =>
            {
                prms = new ServiceNode <object, OurServicesDTO>(_fc)
                       .GetClient("/api/v1/OurServices/OurServicesGetById/" + serviceId + "/" + langId).Data;
            });
            Task tsk2 = Task.Factory.StartNew(() =>
            {
                service = new ServiceNode <object, ServiceInfo>(_fc)
                          .GetClient("/api/v1/serviceinfo/get/" + serviceId + "/" + langId).Data;
            });
            Parallel.Invoke();
            tsk1.Wait();
            tsk2.Wait();
            ServiceInfoViewModel model = new ServiceInfoViewModel();
            model.ServiceInfo   = service;
            model.ServiceParams = prms;
            #endregion
            return(View("ServiceInfo", model));
        }
示例#2
0
        public IActionResult WhatWeDoAdd([FromBody] OurServicesDTO request)
        {
            #region FunctionBody
            bool langluagename = _db.Services.Any(t => t.LanguageId == request.LanguageId && t.Name == request.Name);
            if (langluagename)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.AlreadyExists, message: "This is exists")));
            }
            bool data = _wwd.Add(request);
            if (data)
            {
                return(StatusCode(200, new ReturnMessage(message: "Created")));
            }
            return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, code: 500)));

            #endregion
        }
示例#3
0
        public IActionResult OurServicesUpdate([FromBody] OurServicesDTO request)
        {
            bool data = _db.Services.Any(t => t.Id == request.Id);

            if (!data)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound")));
            }
            bool langluagename = _db.Services.Any(t => t.LanguageId == request.LanguageId && t.Name == request.Name);

            if (langluagename)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.AlreadyExists, message: "AlreadyExists")));
            }
            bool datafinal = _wwd.Update(request, request.Id);

            if (datafinal)
            {
                return(Ok(new ReturnMessage()));
            }
            return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, message: "Error Internal Server")));
        }
示例#4
0
        public IActionResult OurServicesDelete(int id)
        {
            bool datafound = _db.Services.Any(t => t.Id == id);

            if (!datafound)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound")));
            }
            Service        data = _db.Services.Find(id);
            OurServicesDTO dto  = new OurServicesDTO
            {
                Id         = id,
                Name       = data.Name,
                LanguageId = data.LanguageId
            };
            bool request = _wwd.Delete(dto);

            if (request)
            {
                return(Ok(new ReturnMessage(200, message: "Success")));
            }
            return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal, message: "Internal server error")));
        }