Beispiel #1
0
        public async Task <ActionResult <ClosedDate> > PostClosedDate(ClosedDate closedDate)
        {
            _context.ClosedDates.Add(closedDate);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetClosedDate", new { id = closedDate.Id }, closedDate));
        }
Beispiel #2
0
        public async Task <IActionResult> PutClosedDate(int id, ClosedDate closedDate)
        {
            if (id != closedDate.Id)
            {
                return(BadRequest());
            }

            _context.Entry(closedDate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClosedDateExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
        }         // DeepClone

        public override string ToString()
        {
            string closedDateStr = ClosedDate.HasValue
                                ? string.Format(" (closed on {0})", ClosedDate.DateStr())
                                : string.Empty;

            return(string.Format(
                       "on {0}: {1} at {2}{3}",
                       Date.DateStr(),
                       Principal.ToString("C2", Culture),
                       InterestRate.ToString("P1", Culture),
                       closedDateStr
                       ));
        }         // ToString
Beispiel #4
0
        }         // DeepClone

        public override string ToString()
        {
            string closedDateStr = ClosedDate.HasValue
                                ? string.Format(" (closed on {0})", ClosedDate.DateStr())
                                : string.Format(" (open principal {0})", OpenPrincipal.ToString("C2", Library.Instance.Culture));

            string repaymentsStr = HasRepayments
                                ? string.Format(" (repaid: {0})", string.Join(", ", this.principalRepayments))
                                : string.Empty;

            return(string.Format(
                       "on {0}: {1} at {2}{3}{4}",
                       Date.DateStr(),
                       Principal.ToString("C2", Library.Instance.Culture),
                       InterestRate.ToString("P1", Library.Instance.Culture),
                       closedDateStr,
                       repaymentsStr
                       ));
        }         // ToString
        public static void Initialize(AmsApiDbContext context, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager, ILogger <DbInitializer> logger)
        {
            context.Database.EnsureCreated();



            var locations = new Location[] {
                new Location {
                    Active = true, Address = "7696 NW Greensprint St", Address1 = "Suit 123", ContactEmail = "*****@*****.**", ContactName = "Contact PersonNAme", Description = "Este es un salo de belleza", State = "FL", ZipCode = "34987", Country = "US", Phone = "1234567890", City = "Port Saint Lucie"
                },
                new Location {
                    Active = true, Address = "123 NW Greensprint St", Address1 = "Suit 434", ContactEmail = "*****@*****.**", ContactName = "PersonNAme", Description = "Este es una barberia", State = "GA", ZipCode = "3093", Country = "US", Phone = "1234567811", City = "Port Saint Lucie"
                },
            };

            if (!context.Locations.Any())
            {
                //return;   // DB has been seeded

                context.Locations.AddRange(locations);

                context.SaveChanges();
            }
            var cds = new ClosedDate[] {
                new ClosedDate {
                    Location = locations.FirstOrDefault(), Description = "Holyday 2", From = DateTime.Now.AddDays(55), To = DateTime.Now.AddDays(55)
                },
                new ClosedDate {
                    Location = locations.FirstOrDefault(), Description = "Holyday 1", From = DateTime.Now.AddDays(5), To = DateTime.Now.AddDays(5)
                },
            };

            if (!context.ClosedDates.Any())
            {
                //return;   // DB has been seeded


                context.ClosedDates.AddRange(cds);

                context.SaveChanges();
            }



            var scs = new ServiceCategory[] {
                new ServiceCategory {
                    Description = "Haircuts and Hairdressing"
                },
                new ServiceCategory {
                    Description = "Color"
                }
            };

            if (!context.ServiceCategories.Any())
            {
                context.ServiceCategories.AddRange(scs);

                context.SaveChanges();
            }

            var ss = new Service[] {
                new Service {
                    ServiceCategory = scs.Single(s => s.Description == "Haircuts and Hairdressing"), ActiveStatus = true, DurationHour = 1, DurationMinute = 30, Price = 50.00m, ServiceDescription = "Modern Hair cuts", ServiceName = "Hair Cuts"
                },
                new Service {
                    ServiceCategory = scs.Single(s => s.Description == "Haircuts and Hairdressing"), ActiveStatus = true, DurationHour = 1, DurationMinute = 15, Price = 45.00m, ServiceDescription = "Modern Hair cuts", ServiceName = "Wash"
                },
                new Service {
                    ServiceCategory = scs.Single(s => s.Description == "Haircuts and Hairdressing"), ActiveStatus = true, DurationHour = 1, DurationMinute = 30, Price = 50.00m, ServiceDescription = "Hoof cuts", ServiceName = "Manicure and Pedicure"
                },
            };

            if (!context.Services.Any())
            {
                context.Services.AddRange(ss);
                context.SaveChanges();
            }


            var clients = new Client[] {
                new Client {
                    AcceptsMarketingNotifications = true, Active = true, Email = "*****@*****.**", FirstName = "Client1", LastName = "last 1", Mobile = "1234567890", SendNotificationBy = "phone", Photo = "234234"
                },
                new Client {
                    AcceptsMarketingNotifications = true, Active = true, Email = "*****@*****.**", FirstName = "Client 2", LastName = "last 2", Mobile = "1234567890", SendNotificationBy = "email", Photo = "234234"
                },
                new Client {
                    AcceptsMarketingNotifications = true, Active = true, Email = "*****@*****.**", FirstName = "Client 3", LastName = "last 3", Mobile = "1234567890", SendNotificationBy = "email", Photo = "234234"
                },
            };

            if (!context.Clients.Any())
            {
                context.Clients.AddRange(clients);

                context.SaveChanges();
            }

            var uRoles = new IdentityRole {
                Name = "admin", ConcurrencyStamp = "adminrole"
            };
            IdentityResult resultR = roleManager.CreateAsync(uRoles).Result;

            uRoles = new IdentityRole {
                Name = "staff", ConcurrencyStamp = "staffrole"
            };
            resultR = roleManager.CreateAsync(uRoles).Result;
            uRoles  = new IdentityRole {
                Name = "customer", ConcurrencyStamp = "customerrole"
            };
            resultR = roleManager.CreateAsync(uRoles).Result;


            var aUser = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", EmailConfirmed = true
            };
            var result = userManager.CreateAsync(aUser, "Password1$").Result;


            var resultRole = userManager.AddToRoleAsync(aUser, "customer").Result;


            if (result.Succeeded)
            {
                logger.LogInformation("User created a new account with password.");

                var token   = userManager.GenerateEmailConfirmationTokenAsync(aUser).Result;
                var results = userManager.ConfirmEmailAsync(aUser, token).Result;

                aUser = new ApplicationUser {
                    UserName = "******", Email = "*****@*****.**", EmailConfirmed = true
                };
                results    = userManager.CreateAsync(aUser, "Password1$").Result;
                resultRole = userManager.AddToRoleAsync(aUser, "customer").Result;

                token   = userManager.GenerateEmailConfirmationTokenAsync(aUser).Result;
                results = userManager.ConfirmEmailAsync(aUser, token).Result;


                aUser = new ApplicationUser {
                    UserName = "******", Email = "*****@*****.**", EmailConfirmed = true
                };
                userManager.CreateAsync(aUser, "Password1$").Wait();
                resultRole = userManager.AddToRoleAsync(aUser, "customer").Result;
            }
            var sts = new Staff[] {
                new Staff {
                    Active = true, BriefCv = "Nice cuts", CanBook = true, Email = "*****@*****.**", FirstName = "Staly 1", LastName = "st", Mobile = "1234567890", Title = "Cutter"
                },
                new Staff {
                    Active = true, BriefCv = "Nice cuts same", CanBook = true, Email = "*****@*****.**", FirstName = "St3", LastName = "tr", Mobile = "1234563333", Title = "Very good"
                },
                new Staff {
                    Active = true, BriefCv = "D' Penco Nice cuts same", CanBook = true, Email = "*****@*****.**", FirstName = "the", LastName = "penco", Mobile = "1234562233", Title = "The Penco"
                },
            };

            if (!context.Staffs.Any())
            {
                context.Staffs.AddRange(sts);
                context.SaveChanges();
            }

            aUser = new ApplicationUser {
                UserName = "******", Email = "*****@*****.**", EmailConfirmed = true
            };
            result     = userManager.CreateAsync(aUser, "Password1$").Result;
            resultRole = userManager.AddToRoleAsync(aUser, "staff").Result;

            if (result.Succeeded)
            {
                var token   = userManager.GenerateEmailConfirmationTokenAsync(aUser).Result;
                var results = userManager.ConfirmEmailAsync(aUser, token).Result;

                aUser = new ApplicationUser {
                    UserName = "******", Email = "*****@*****.**", EmailConfirmed = true
                };
                userManager.CreateAsync(aUser, "Password1$").Wait();
                resultRole = userManager.AddToRoleAsync(aUser, "admin").Result;

                token   = userManager.GenerateEmailConfirmationTokenAsync(aUser).Result;
                results = userManager.ConfirmEmailAsync(aUser, token).Result;

                aUser = new ApplicationUser {
                    UserName = "******", Email = "*****@*****.**", EmailConfirmed = true
                };
                userManager.CreateAsync(aUser, "Password1$").Wait();
                resultRole = userManager.AddToRoleAsync(aUser, "staff").Result;
            }

            var whs = new StaffWorkingHour[] {
                new StaffWorkingHour {
                    EndRepeat = EndRepeat.Ongoing, From = DateTime.Now, To = DateTime.Now.AddHours(5), Location = locations.FirstOrDefault(), Staff = sts.FirstOrDefault()
                },
                new StaffWorkingHour {
                    EndRepeat = EndRepeat.Ongoing, From = DateTime.Now, To = DateTime.Now.AddHours(3), Location = locations.LastOrDefault(), Staff = sts.LastOrDefault()
                },
            };

            if (!context.StaffWorkingHours.Any())
            {
                context.StaffWorkingHours.AddRange(whs);

                context.SaveChanges();
            }
        }