public IActionResult Update([FromBody] UserDTO request, int Id)
        {
            #region FunctionBody
            bool exist = _db.Users.Any(c => c.Id == Id);
            if (!exist)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound)));
            }
            string hashed = Crypto.HashPassword(request.Password);
            string pKey   = Hasher.EncryptString(request.Password, _configuration["Jwt:Key"]);
            request.Password = hashed;
            request.PKey     = pKey;
            List <User> alreadyExist = _db.Users.Where(a => a.PhoneNumber == request.PhoneNumber || a.Email == request.Email).ToList();
            if (alreadyExist.Count > 1)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.AlreadyExists, message: "This credentials is used by another account")));
            }
            bool IsExisted = alreadyExist.Any(b => b.Id == Id);
            if (!IsExisted)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.AlreadyExists, message: "This credentials is used by another account")));
            }
            bool IsUpdated = _userService.Update(request, Id);
            if (!IsUpdated)
            {
                return(StatusCode(500, new ReturnErrorMessage((int)ErrorTypes.Errors.Internal)));
            }
            return(Ok(new ReturnMessage()));

            #endregion
        }
        public IActionResult WhatWeDoUpdate([FromBody] WhatWeDoDTO request)
        {
            bool data = _db.WhatWeDos.Any(t => t.Id == request.Id);

            if (!data)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound")));
            }
            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")));
        }
Beispiel #3
0
        public IActionResult ContactUsUpdate([FromBody] ContactUsDTO request)
        {
            #region FunctionBody
            bool data = _db.ContactUss.Any(t => t.Id == request.Id);
            if (!data)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound")));
            }
            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")));

            #endregion
        }
        public IActionResult ServicesUpdate([FromBody] ServiceInfo request)
        {
            bool data = _db.ServiceInfos.Any(t => t.Id == request.Id);

            if (!data)
            {
                return(StatusCode(400, new ReturnErrorMessage((int)ErrorTypes.Errors.NotFound, message: "NotFound")));
            }
            bool langluagename = _db.ServiceInfos.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")));
        }