コード例 #1
0
ファイル: Logic.cs プロジェクト: tesfa-ozem/Accounts
        public AppUserResult AddNewMember(AgentsViewModel agentsViewModel)
        {
            try
            {
                UHCContext context = new UHCContext();

                AppUsers agent = (new AppUsers
                {
                    IdNumber = agentsViewModel.IdNumber,
                    FirstName = agentsViewModel.FirstName,
                    LastName = agentsViewModel.LastName,
                    PhoneNumber = agentsViewModel.PhoneNumber,
                    SUBCOUNTY = agentsViewModel.SUBCOUNTY,
                    WARD = agentsViewModel.WARD,
                    VILLAGE = agentsViewModel.VILLAGE,
                    Password = agentsViewModel.Password,
                    UserName = agentsViewModel.UserName,

                    DateRegistered = DateTime.Now.Date
                });

                SendSMSAsync(agent);
                context.Add(agent);
                context.SaveChanges();
                return(new AppUserResult()
                {
                });
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
ファイル: Logic.cs プロジェクト: tesfa-ozem/Accounts
        public AppUserResult DeletUser(string Idnumber)
        {
            try
            {
                UHCContext context = new UHCContext();

                var key   = context.AppUsers.Where(e => e.IdNumber == Idnumber).FirstOrDefault();
                var Agent = context.AppUsers.Find(key.Id);

                context.AppUsers.Remove(Agent);
                context.SaveChanges();
                return(new AppUserResult()
                {
                });
            }
            catch (Exception)
            {
                return(new AppUserResult()
                {
                });
            }
        }
コード例 #3
0
ファイル: Logic.cs プロジェクト: tesfa-ozem/Accounts
        public string SendSMSAsync(AppUsers agents)
        {
            try
            {
                UHCContext context = new UHCContext();


                Sms sms = new Sms();

                Random random = new Random();
                int    pin    = random.Next(1000, 9999);
                string msg    = string.Format("Dear {0} your KChic login credentials are : username : {1}, password : {2}", agents.FirstName, agents.UserName, pin);
                sms.SendSms(agents.PhoneNumber, msg);
                agents.Password = Security.EncryptString(pin.ToString(), Security.pPhrase);



                return("");
            }
            catch (Exception)
            {
            }
            return("");
        }