Пример #1
0
        public ProgressStatus UserRegister([FromForm] RegisterViewModel registerViewModel)
        {
            var Result = new ProgressStatus();

            try
            {
                if (_Customer.CheckCustomerEmailExisting(registerViewModel.Email).Number.Equals(2))
                {
                    AirPortModel.Models.Customer customerobj = new AirPortModel.Models.Customer();
                    customerobj.Name     = registerViewModel.Name;
                    customerobj.LastName = registerViewModel.LastName;
                    customerobj.Email    = registerViewModel.Email;
                    customerobj.Password = PasswordHelper.EncodePasswordMd5(registerViewModel.Password);
                    if (_Customer.Insert(customerobj) != 0)
                    {
                        var tokenDescriptor = new SecurityTokenDescriptor
                        {
                            Subject = new ClaimsIdentity(new Claim[]
                            {
                                new Claim("Customer", _Customer.FindByEmail(registerViewModel.Email).Id.ToString())
                            }),
                            Expires            = DateTime.UtcNow.AddYears(1),
                            SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_appSettings.JWT_Token)), SecurityAlgorithms.HmacSha256Signature)
                        };
                        var    tokenHandler  = new JwtSecurityTokenHandler();
                        var    securityToken = tokenHandler.CreateToken(tokenDescriptor);
                        string token         = tokenHandler.WriteToken(securityToken);
                        Result = new ProgressStatus {
                            Message = " ثبت نام با موفقیت انجام شد", Number = 1, Title = "Register Successful !", Token = token
                        };
                        return(Result);
                    }
                    else
                    {
                        Result = new ProgressStatus {
                            Message = " ثبت نام با موفقیت انجام نشد", Number = 1, Title = "Register Successful !"
                        };
                        return(Result);
                    }
                }
                else
                {
                    Result = new ProgressStatus {
                        Message = "کاربری با این ایمیل موجود می باشد", Number = 2, Title = "Register UnSuccessful !"
                    };
                    return(Result);
                }
            }
            catch (Exception ex)
            {
                Result = new ProgressStatus {
                    Message = ex.Message, Number = 0, Title = "Unhandeled ERROR !"
                };
                return(Result);
            }
        }
Пример #2
0
        public List <ToDoListViewModel> tolist([FromForm] string email)
        {
            ToDoListViewModel        todoobj     = new ToDoListViewModel();
            List <ToDoListViewModel> todolistobj = new List <ToDoListViewModel>();

            try
            {
                if (_customer.CheckCustomerEmailExisting(email).Number.Equals(1))
                {
                    AirPortModel.Models.Customer customerobj = _customer.FindByEmail(email);
                    if (_flighttodo.FindByCustumerId(customerobj.Id) != null)
                    {
                        var listtodo = _flighttodo.FindByCustumerId(customerobj.Id);
                        foreach (var item in listtodo)
                        {
                            todoobj.id          = item.id;
                            todoobj.Name        = item.Name;
                            todoobj.LastUpdate  = item.LastUpdate;
                            todoobj.IsDon       = item.IsDon;
                            todoobj.FlightId    = item.FlightId;
                            todoobj.DateCreate  = item.DateCreate;
                            todoobj.Description = item.Description;
                            todoobj.LastUpdate  = item.LastUpdate;
                            todolistobj.Add(todoobj);
                        }
                        return(todolistobj);
                    }
                    else
                    {
                        return(todolistobj);
                    }
                }
                else
                {
                    return(todolistobj);
                }
            }
            catch (Exception ex)
            {
                string mes = ex.Message;
                return(todolistobj);
            }
        }