Пример #1
0
        public async Task <data.User> Add(data.ToDoDbContext db, UserAdd add)
        {
            try
            {
                var newUser = new data.User();
                newUser.Email        = add.Email;
                newUser.FirstName    = add.FirstName;
                newUser.MobileNumber = add.MobileNumber;
                newUser.Surname      = add.Surname;
                newUser.Title        = add.Title;

                // Add references to parent Classes


                db.Users.Add(newUser);

                return(newUser);
            }

            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }
Пример #2
0
        public async Task <data.User> Add(UserAdd add)
        {
            try
            {
                var newUser = new data.User();
                newUser.AddressLine1 = add.AddressLine1;
                newUser.AddressLine2 = add.AddressLine2;
                newUser.City         = add.City;
                newUser.Company      = add.Company;
                newUser.Country      = add.Country;
                newUser.Department   = add.Department;
                newUser.Email        = add.Email;
                newUser.FirstName    = add.FirstName;
                newUser.HomeNumber   = add.HomeNumber;
                newUser.MobileNumber = add.MobileNumber;
                newUser.Postcode     = add.Postcode;
                newUser.Surname      = add.Surname;
                newUser.Title        = add.Title;
                newUser.WorkNumber   = add.WorkNumber;

                newUser.UserId = await data.Sequence.SequenceGenerator.GetNextId("User");

                newUser.RowKey       = newUser.UserId.ToString();
                newUser.PartitionKey = "root";
                TableOperation insertOperation = TableOperation.Insert(newUser);
                var            userTable       = await data.Utils.GetTable("User");

                await userTable.ExecuteAsync(insertOperation);

                return(newUser);
            }

            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(null);
            }
        }