示例#1
0
        protected override PartStream reportPart(Dispositions dispositions)
        {
            LastDispositions = dispositions;
            LastStream       = new TestPartStream();

            return(LastStream);
        }
        public IActionResult CreateCustomer(CreateCustomerViewModel model)
        {
            if (ModelState.IsValid)
            {
                Accounts account = new Accounts
                {
                    Created   = DateTime.Now,
                    Frequency = "Monthly",
                    Balance   = 0m,
                };

                Dispositions disposition = new Dispositions
                {
                    Type     = "Owner",
                    Customer = model.Customer,
                    Account  = account
                };

                model.Accounts     = account;
                model.Dispositions = disposition;
                _context.AddRange(model.Customer, model.Dispositions, model.Accounts);
                _context.SaveChanges();

                return(RedirectToAction("Index", "Home"));
            }

            return(View(model));
        }
示例#3
0
        public string CreateCustomer(CreateCustomerServiceModel model)
        {
            //Den nya kunden ska också få ett "startkonto"

            Customers newCustomer = _mapper.Map <CreateCustomerServiceModel, Customers>(model);

            newCustomer.UniqueId = Guid.NewGuid().ToString();
            _context.Customers.Add(newCustomer);

            Accounts newAccount = new Accounts()
            {
                Balance = 0, Created = DateTime.Today, Frequency = "Monthly"
            };

            _context.Accounts.Add(newAccount);

            _context.SaveChanges();

            Dispositions newDisposition = new Dispositions()
            {
                AccountId = newAccount.AccountId, CustomerId = newCustomer.CustomerId, Type = "OWNER"
            };

            _context.Dispositions.Add(newDisposition);
            _context.SaveChanges();

            _searchService.CreateCustomerData(_mapper.Map <Customers, CustomerIndex>(newCustomer));

            return(newCustomer.UniqueId);
        }
示例#4
0
 public void BuildNPCFromEmbed(Embed embed)
 {
     foreach (var aspectField in embed.Fields.Where(fld => fld.Name == StarforgedNPCResources.Aspect))
     {
         Aspects.Add(aspectField.Value);
     }
     foreach (var dispositionField in embed.Fields.Where(fld => fld.Name == StarforgedNPCResources.Disposition))
     {
         Dispositions.Add(dispositionField.Value);
     }
     foreach (var firstLook in embed.Fields.Where(fld => fld.Name == StarforgedNPCResources.FirstLook))
     {
         FirstLooks.Add(firstLook.Value);
     }
     foreach (var goal in embed.Fields.Where(fld => fld.Name == NPCResources.Goal))
     {
         Goals.Add(goal.Value);
     }
     foreach (var role in embed.Fields.Where(fld => fld.Name == NPCResources.Role))
     {
         Roles.Add(role.Value);
     }
     Name      = embed.Fields.FirstOrDefault(fld => fld.Name == NPCResources.Name).Value;
     IconUrl   = embed.Thumbnail.HasValue ? embed.Thumbnail.Value.Url : null;
     EmbedDesc = embed.Description;
 }
示例#5
0
 public void BuildNPCFromEmbed(Embed embed)
 {
     foreach (var activityField in embed.Fields.Where(fld => fld.Name == NPCResources.Activity))
     {
         Activities.Add(activityField.Value);
     }
     foreach (var dispositionField in embed.Fields.Where(fld => fld.Name == NPCResources.Disposition))
     {
         Dispositions.Add(dispositionField.Value);
     }
     foreach (var goal in embed.Fields.Where(fld => fld.Name == NPCResources.Goal))
     {
         Goals.Add(goal.Value);
     }
     foreach (var role in embed.Fields.Where(fld => fld.Name == NPCResources.Role))
     {
         Roles.Add(role.Value);
     }
     foreach (var desc in embed.Fields.Where(fld => fld.Name == NPCResources.Descriptor))
     {
         Descriptors.Add(desc.Value);
     }
     Name      = embed.Fields.FirstOrDefault(fld => fld.Name == NPCResources.Name).Value;
     IconUrl   = embed.Thumbnail.HasValue ? embed.Thumbnail.Value.Url : null;
     EmbedDesc = embed.Description;
 }
        public async Task <DispositionUser[]> GetDispositionAsync(DateTime date, long hourId)
        {
            await AuthenticateAsync();

            //https://wielkomiejskie.org/api/v1/witnessings/11/schedule/dispositions?date=2019-03-13&hour_id=263&search_query=
            var url =
                $@"{GetBaseUrl()}/schedule/dispositions?date={date.Year}-{date.Month:D2}-{date.Day:D2}&hour_id={hourId}&search_query=";

            var witnessingMembersResponse = await _httpClient.GetAsync(url);

            if (await CheckResultIsOk(witnessingMembersResponse))
            {
                var responseVal = await witnessingMembersResponse.Content.ReadAsStringAsync();

                var fromJson = Dispositions.FromJson(responseVal);


                var fromJsonUsers = fromJson.Users;


                var schedulesForThisDay = await GetScheduleAsync(date);

                var witnessingScheduleMembers = schedulesForThisDay.Where(s => s.HourId == hourId).ToList();

                if (cachedMembers == null)
                {
                    cachedMembers = await GetMembersAsync();
                }

                foreach (var witnessingScheduleMember in witnessingScheduleMembers)
                {
                    DispositionUser h = new DispositionUser();

                    var witnessingMember = cachedMembers.Single(m => m.Id == witnessingScheduleMember.UserId);

                    h.Date      = witnessingScheduleMember.Date.DateTime;
                    h.HourId    = witnessingScheduleMember.HourId;
                    h.FirstName = witnessingMember.FirstName;
                    h.LastName  = witnessingMember.LastName;
                    h.Email     = witnessingMember.Email;
                    var fromJsonUsersTmp = fromJsonUsers.ToList();
                    fromJsonUsersTmp.Add(h);

                    fromJsonUsers = fromJsonUsersTmp.ToArray();
                }

                foreach (var dispositionUser in fromJsonUsers)
                {
                    dispositionUser.HourId = hourId;
                    dispositionUser.Date   = date;
                }


                return(fromJsonUsers);
            }

            return(null);
        }
        public IActionResult CreateCustomer(CreateCustomerViewModel register)
        {
            if (ModelState.IsValid)
            {
                Customers newCustomer = new Customers()
                {
                    Gender               = register.Gender,
                    Givenname            = register.Givenname,
                    Surname              = register.Surname,
                    Streetaddress        = register.Streetaddress,
                    City                 = register.City,
                    Zipcode              = register.Zipcode,
                    Country              = register.Country,
                    CountryCode          = register.CountryCode,
                    Birthday             = register.Birthday,
                    NationalId           = register.NationalId,
                    Telephonecountrycode = register.Telephonecountrycode,
                    Telephonenumber      = register.Telephonenumber,
                    Emailaddress         = register.Emailaddress
                };

                Accounts account = new Accounts()
                {
                    Frequency = "Monthly",
                    Created   = DateTime.Now,
                    Balance   = 0m
                };

                Dispositions disposition = new Dispositions()
                {
                    Type     = "Owner",
                    Customer = newCustomer,
                    Account  = account
                };

                register.Account     = account;
                register.Disposition = disposition;

                _context.Add(newCustomer);
                _context.Add(register.Account);
                _context.Add(register.Disposition);

                _context.SaveChanges();


                return(RedirectToAction("CreateCustomerSuccess"));
            }
            else
            {
                return(View(register));
            }
        }
示例#8
0
        public async Task <bool> CreateCustomer(Customers customer)
        {
            if (customer == null)
            {
                return(false);
            }

            switch (customer.Country)
            {
            case "Sweden":
                customer.CountryCode          = CountryCodeType.SE.ToString();
                customer.Telephonecountrycode = "46";
                break;

            case "Denmark":
                customer.CountryCode          = CountryCodeType.DK.ToString();
                customer.Telephonecountrycode = "45";
                break;

            case "Norway":
                customer.CountryCode          = CountryCodeType.NO.ToString();
                customer.Telephonecountrycode = "47";
                break;

            case "Finland":
                customer.CountryCode          = CountryCodeType.FI.ToString();
                customer.Telephonecountrycode = "358";
                break;
            }

            var account = new Accounts
            {
                Balance   = 0m,
                Created   = DateTime.Now,
                Frequency = FrequencyType.Monthly.ToString()
            };

            await _customerRepository.Create(customer);

            await _accountRepository.Create(account);

            var disposition = new Dispositions
            {
                CustomerId = customer.CustomerId,
                AccountId  = account.AccountId,
                Type       = DispositionType.OWNER.ToString()
            };

            await _dispositionRepository.Create(disposition);

            return(true);
        }
示例#9
0
        public async Task <bool> Create(Dispositions disposition)
        {
            if (disposition == null)
            {
                return(false);
            }

            await _context.Dispositions.AddAsync(disposition);

            await _context.SaveChangesAsync();

            return(true);
        }
        public IActionResult NewCustomer(CustomerMessageViewModel values)
        {
            if (values.Customer.CustomerId == 0)
            {
                if (ModelState.IsValid)
                {
                    _context.Customers.Add(values.Customer);

                    Accounts newAccount = new Accounts();
                    newAccount.Balance   = 0;
                    newAccount.Frequency = "Monthly";
                    newAccount.Created   = DateTime.Now;
                    _context.Accounts.Add(newAccount);

                    Dispositions newDisposition = new Dispositions();
                    newDisposition.AccountId  = newAccount.AccountId;
                    newDisposition.CustomerId = values.Customer.CustomerId;
                    newDisposition.Type       = "OWNER";
                    _context.Dispositions.Add(newDisposition);

                    _context.SaveChanges();
                    ModelState.Clear();

                    values.Message = "Kunden har lagts till i kundregistret. Ett transaktionskonto för kunden har även skapats.";

                    return(View(values));
                }
                else
                {
                    values.Message = "Kunden har ej lagts till i kundregistret. Vänligen kontrollera att alla obligatoriska fält är ifyllda.";
                    return(View(values));
                }
            }
            else
            {
                if (ModelState.IsValid)
                {
                    var old = _context.Customers.SingleOrDefault(c => c.CustomerId == values.Customer.CustomerId);

                    _context.Entry(old).CurrentValues.SetValues(values.Customer);
                    _context.SaveChanges();
                    ModelState.Clear();

                    values.Message = "Kundinformationen har uppdaterats";

                    return(View(values));
                }
                values.Message = "Kundinformationen kunde ej sparas. Kontrollera att alla obligatoriska fält är ifyllda.";
                return(View(values));
            }
        }
示例#11
0
        public override string ToString()
        {
            int maxItemId;

            if (Dispositions.Length > 0)
            {
                maxItemId = Dispositions
                            .Select(x => x.Item.ID)
                            .Max();
            }
            else
            {
                maxItemId = 0;
            }
            var idLength = maxItemId.ToString().Length;

            var format      = $"[{{0,{idLength}:d{idLength}}}]";
            var emptyFloor  = string.Format("[{0}]", new string(' ', idLength));
            var actionPoint = string.Format("[{0}]", new string('#', idLength));

            var result = new StringBuilder();

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    string floor;
                    var    id = FloorSummary[x, y];
                    if (id.HasValue)
                    {
                        floor = string.Format(format, id.Value);
                    }
                    else
                    {
                        var p = new Point(x, y);
                        if (Dispositions.Select(d => d.Location).Contains(p))
                        {
                            floor = actionPoint;
                        }
                        else
                        {
                            floor = emptyFloor;
                        }
                    }
                    result.Append(floor);
                }
                result.Append(Environment.NewLine);
            }

            return(result.ToString());
        }
示例#12
0
 public Embed GetEmbed()
 {
     return(new EmbedBuilder()
            .WithTitle($"__{NPCResources.NPCTitle}__")
            .WithThumbnailUrl(IconUrl)
            .WithFields(new EmbedFieldBuilder().WithName(NPCResources.Name).WithValue(Name).WithIsInline(false))
            .WithFields(Roles.EmbedFieldBuilderFromList(NPCResources.Role, true))
            .WithFields(Goals.EmbedFieldBuilderFromList(NPCResources.Goal, true))
            .WithFields(Descriptors.EmbedFieldBuilderFromList(NPCResources.Descriptor, true))
            .WithFields(Activities.EmbedFieldBuilderFromList(NPCResources.Activity, true))
            .WithFields(Dispositions.EmbedFieldBuilderFromList(NPCResources.Disposition, true))
            .WithFooter(GameName.Ironsworn.ToString())
            .WithDescription(EmbedDesc)
            .Build());
 }
示例#13
0
        private void SeedData(BankAppDataContext context)
        {
            if (context.Customers.FirstOrDefault(x => x.Username == "TestApiUser") == null)
            {
                var testApiCustomer = new Customers()
                {
                    Username             = "******",
                    Password             = "******",
                    Birthday             = new DateTime(1980, 08, 16),
                    City                 = "Stockholm",
                    Country              = "Sweden",
                    Emailaddress         = "*****@*****.**",
                    UniqueId             = "03ECF1B1-D2DC-499B-B9A0-46890F705DA9",
                    CountryCode          = "SE",
                    Gender               = "Male",
                    Givenname            = "Test",
                    Surname              = "Testsson",
                    Streetaddress        = "testgatan",
                    Zipcode              = "16762",
                    Telephonecountrycode = "46",
                    Telephonenumber      = "0702675432"
                };
                context.Customers.Add(testApiCustomer);

                Accounts newTestAccount = new Accounts()
                {
                    Balance = 100, Created = DateTime.Today, Frequency = "Monthly"
                };
                context.Accounts.Add(newTestAccount);

                context.SaveChanges();

                Dispositions newDisposition = new Dispositions()
                {
                    AccountId = newTestAccount.AccountId, CustomerId = testApiCustomer.CustomerId, Type = "OWNER"
                };

                context.Dispositions.Add(newDisposition);
                context.SaveChanges();
            }
        }
        public ManageCustomerViewModel RegisterCustomer(ManageCustomerViewModel model)
        {
            var newCustomer = new Customers()
            {
                Givenname     = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.GivenName),
                Surname       = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Surname),
                Emailaddress  = model.Email.ToLower(),
                Streetaddress = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Address),
                City          = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.City),
                NationalId    = model.NationalId,
                Country       = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(model.Country),
                CountryCode   = model.CountryCode.ToUpper(),
                Gender        = model.ChosenGender,
                Zipcode       = model.ZipCode
            };

            _context.Customers.Add(newCustomer);

            var newAccount = new Accounts()
            {
                Created   = DateTime.Now,
                Balance   = 0,
                Frequency = "Monthly"
            };

            _context.Accounts.Add(newAccount);

            var newDisposition = new Dispositions
            {
                Account  = newAccount,
                Customer = newCustomer,
                Type     = "Owner"
            };

            _context.Dispositions.Add(newDisposition);

            _context.SaveChanges();
            model.AccountId = newAccount.AccountId;
            return(model);
        }
示例#15
0
        /// <summary>
        /// 現在のルームに新しいアイテムを配置できるかを確認し、配置できる場合には現在のルームに新しいアイテムを配置したルームを返却する。
        /// </summary>
        /// <param name="newDisposition">配置するアイテムの情報</param>
        /// <param name="addedRoom">アイテムが追加されたルーム</param>
        /// <returns>アイテムが追加された場合はtrue、追加できなかった場合はfalse</returns>
        /// <remarks>
        /// このメソッドがtrueを返却した場合にも現在のルームは変更されない。
        /// 現在のルームに新しいアイテムが追加されたルームが作成され、addedRoomに返却される。
        /// </remarks>
        public bool TryAddItem(ItemDisposition newDisposition, out Room addedRoom)
        {
            var addPoint = newDisposition.Location;
            var newItem  = newDisposition.Item;

            var newFreeFloorList = new List <Point>(FreeFloors);
            var occupationPoints = newItem.Occupation.ToRoomCoordination(addPoint);

            foreach (var p in occupationPoints)
            {
                if (!newFreeFloorList.Remove(p))
                {
                    addedRoom = none;
                    return(false);
                }
            }
            var newFreeFloors = newFreeFloorList.ToArray();

            var newWidth  = Width;
            var newHeight = Height;

            var newDispositions = new ItemDisposition[Dispositions.Length + 1];

            Dispositions.CopyTo(newDispositions, 0);
            newDispositions[newDispositions.Length - 1] = newDisposition;

            var newFloorSummary = (int?[, ])FloorSummary.Clone();

            foreach (var p in occupationPoints)
            {
                newFloorSummary[p.X, p.Y] = newItem.ID;
            }

            addedRoom = new Room(newWidth, newHeight, newDispositions, newFreeFloors, newFloorSummary);
            return(true);
        }
示例#16
0
 /// <summary>
 /// Report all part entries. Whole part content will be
 /// written into returned PartStream.
 /// </summary>
 /// <param name="dispositions">Content dispositions parsed for reported.</param>
 /// <returns>PartStream used for writing part stream.</returns>
 protected abstract PartStream reportPart(Dispositions dispositions);
 public void Create(Dispositions disposition)
 {
     dbContext.Dispositions.Add(disposition);
     dbContext.SaveChanges();
 }
示例#18
0
        private int reportHeaderContent(byte[] data, int dataOffset, int dataLength)
        {
            int i;

            for (i = dataOffset; i < dataOffset + dataLength; ++i)
            {
                var b  = data[i];
                var ch = (char)b;

                switch (ch)
                {
                case '\r':
                    //no action
                    break;

                case ':':
                    //key confirmation
                    _dispositionKey = stringyBuffer();
                    _buffer.Clear();

                    break;

                case '\n':
                    //buffer confirmation

                    var value = stringyBuffer();
                    _buffer.Clear();

                    if (_dispositions == null)
                    {
                        //disposition section hasn't been started yet

                        if (value == "--")
                        {
                            //end of last part
                            ContinueDownloading = false;
                            return(int.MaxValue);
                        }

                        if (value == "")
                        {
                            //open disposition section
                            _dispositions = new Dispositions();
                            continue;
                        }
                        Log.Error("Unexpected dispositions key: {0}", value);
                        ContinueDownloading = false;
                        return(int.MaxValue);
                    }

                    if (_dispositionKey == null)
                    {
                        //no key in open dispositions section means end of section
                        onSectionComplete();
                        if (_currentPartStream == null)
                        {
                            ContinueDownloading = false;
                        }

                        _dispositions = null;
                        return(i + 1);
                    }

                    _dispositions[_dispositionKey] = value;
                    //reset key
                    _dispositionKey = null;
                    break;

                default:
                    if (_buffer.Count == 0 && char.IsWhiteSpace(ch))
                    {
                        //remove trailing white chars
                        break;
                    }

                    _buffer.Add(b);
                    break;
                }
            }

            if (_dispositions == null)
            {
                if (_buffer.Count == 2 &&
                    _buffer[0] == '-' &&
                    _buffer[1] == '-'
                    )
                {
                    //end of last part
                    ContinueDownloading = false;
                    return(i);
                }
            }

            return(i);
        }
 public void Update(Dispositions disposition)
 {
     dbContext.Dispositions.Update(disposition);
     dbContext.SaveChanges();
 }