예제 #1
0
        public int Insert(AirPortModel.Models.Customer obj)
        {
            try
            {
                //*****************chek shavad hatma************************************
                AirPortModel.Models.Address Oaddress = new AirPortModel.Models.Address();
                Address address = new Address(_db);
                obj.address = _db.Adresses.FirstOrDefault(x => x.Id == 4);
                //*****************End chek shavad hatma************************************
                //obj.address = null;
                obj.Mobile       = null;
                obj.ProfileImage = null;
                obj.Sex          = true;
                obj.Isactive     = false;
                obj.IsDelete     = false;

                obj.DateCreate = DateTime.Now;
                obj.LastUpdate = DateTime.Now;
                _db.customers.Add(obj);
                _db.SaveChanges();
                return(obj.Id);
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                return(0);
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
        public ProgressStatus Userprofile([FromForm] ProfileViewModel profileViewModel)
        {
            try
            {
                string Custumerid = User.Claims.First(u => u.Type == "Customer").Value;
                var    result     = new ProgressStatus();
                if (_Customer.FindById(Convert.ToInt32(Custumerid)) != null)
                {
                    AirPortModel.Models.Customer customerobj = _Customer.FindById(Convert.ToInt32(Custumerid));
                    customerobj.Name     = profileViewModel.Name;
                    customerobj.LastName = profileViewModel.LastName;
                    customerobj.Email    = profileViewModel.Email;
                    customerobj.Mobile   = profileViewModel.Mobile;
                    customerobj.Sex      = profileViewModel.Sex;
                    customerobj.BDate    = profileViewModel.Bdate;

                    if (_Customer.Update(customerobj).Number.Equals(1))
                    {
                        result = new ProgressStatus {
                            Number = 1, Title = "Update Successful", Message = "ویرایش با موفقیت انجام شد"
                        };
                        return(result);
                    }
                    else
                    {
                        result = new ProgressStatus {
                            Number = 2, Title = "Update Successful", Message = "ویرایش با مموفقیت انجام نشد"
                        };
                        return(result);
                    }
                }
                else
                {
                    result = new ProgressStatus {
                        Number = 4, Title = "Token NotValid", Message = "توکن معتبر نیست"
                    };
                    return(result);
                }
            }
            catch (Exception ex)
            {
                var result = new ProgressStatus {
                    Number = 0, Title = "UnHandeled Error", Message = ex.Message
                };
                return(result);
            }
        }
예제 #4
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);
            }
        }
예제 #5
0
 public ProgressStatus Update(AirPortModel.Models.Customer obj)
 {
     try
     {
         obj.LastUpdate = DateTime.Now.Date;
         _db.customers.Update(obj);
         _db.SaveChanges();
         var result = new ProgressStatus {
             Number = 1, Title = "update Successful", Message = "Customer Has been Updated"
         };
         return(result);
     }
     catch (Exception ex)
     {
         var result = new ProgressStatus {
             Number = 0, Title = "Update Error", Message = ex.Message
         };
         return(result);
     }
 }