Beispiel #1
0
        public async Task <IActionResult> UpdateModel(UpdateModel updateModel)
        {
            try
            {
                RAdminLoginModel responseUser = null;

                if (!updateModel.Equals(null))
                {
                    //Throws Custom Exception When Fields are Empty Strings.
                    if (updateModel.EmailId == "" || updateModel.Gender == "" || updateModel.Name == "")
                    {
                        throw new Exception(AdminExceptions.ExceptionType.EMPTY_EXCEPTION.ToString());
                    }

                    //Throws Custom Exception When Fields are Empty Strings.
                    if (updateModel.EmailId == null || updateModel.Gender == null || updateModel.Name == null)
                    {
                        throw new Exception(AdminExceptions.ExceptionType.NULL_EXCEPTION.ToString());
                    }

                    string Role  = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "Role").Value;
                    string Email = HttpContext.User.Claims.FirstOrDefault(c => c.Type == "Email").Value;
                    //int RoleId = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(c => c.Type == "RoleId").Value);

                    responseUser = await adminBL.UpdateModel(updateModel, Email);
                }
                else
                {
                    throw new Exception(AdminExceptions.ExceptionType.NULL_EXCEPTION.ToString());
                }

                if (!responseUser.Equals(null))
                {
                    bool Success = true;
                    var  Message = "Model Update Successfull";
                    return(Ok(new { Success, Message, }));
                }
                else
                {
                    bool Success = false;
                    var  Message = "Model Update UnSuccessfull";
                    return(Conflict(new { Success, Message }));
                }
            }
            catch (Exception exception)
            {
                bool Success = false;
                return(BadRequest(new { Success, Message = exception.Message }));
            }
        }