예제 #1
0
        public void Create(LocationApplication application)
        {
            var userWithEmail = _context.Users.FirstOrDefault(x => x.Email == application.Email);

            if (userWithEmail != null)
            {
                throw new AppException("There is already a user registered with this E-Mail address");
            }
            if (!StringExtenstions.IsValid(application.Line1))
            {
                throw new AppException("Address Line 1 cannot be empty.");
            }
            if (!StringExtenstions.IsValid(application.ZipCode))
            {
                throw new AppException("Zip code cannot be empty.");
            }
            if (!StringExtenstions.IsValid(application.Line2))
            {
                throw new AppException("Address Line 2 cannot be empty.");
            }
            if (!StringExtenstions.IsValid(application.Name))
            {
                throw new AppException("The location must have a name.");
            }

            _context.LocationApplications.Add(application);
            _context.SaveChanges();
        }
예제 #2
0
 public LocationApplicationMappings()
 {
     CreateMap <LocationApplicationDto, LocationApplication>()
     .ForMember(x => x.Id, y => y.MapFrom(z => Guid.Parse(z.Id)))
     .ForMember(x => x.LocationType, y => y.MapFrom(z => (LocationTypes)z.LocationTypeId));
     CreateMap <LocationApplication, LocationApplicationDto>()
     .ForMember(x => x.Id, y => y.MapFrom(z => z.Id.ToString()))
     .ForMember(x => x.InsertDateStr, y => y.MapFrom(z => z.InsertDate.ToString("g")))
     .ForMember(x => x.UpdateDateStr, y => y.MapFrom(z => z.UpdateDate.ToString("g")))
     .ForMember(x => x.FullAddress, y => y.MapFrom(z => StringExtenstions.ToFullAddress(z.Line1, z.ZipCode, z.Line2, z.ApartmentNumber)))
     .ForMember(x => x.LocationTypeId, y => y.MapFrom(z => z.LocationType))
     .ForMember(x => x.LocationTypeStr, y => y.MapFrom(z => z.LocationType.ToString()));
 }
        public string ParseTable(string tableText, bool setBorder)
        {
            StringBuilder tableOut = new StringBuilder(1000);

            char[] CRLF = Environment.NewLine.ToCharArray();

            if (setBorder)
            {
                tableOut.Append(TABLE_BORDER);
            }
            else
            {
                tableOut.Append(TABLE);
            }

            tableText = tableText.Replace("“", ((char)34).ToString()).Replace("”", ((char)34).ToString()).Replace("—", "-")
                        .Replace("’", "'").Replace((char)(8211), char.Parse("-"));

            List <string> rows = tableText.Split(CRLF, 100, StringSplitOptions.RemoveEmptyEntries).ToList();
            List <string> cells;
            int           rowCount = 1;

            char[] TAB = StringExtenstions.AsciiToString(9).ToCharArray();

            foreach (string row in rows)
            {
                tableOut.Append(ROW);
                cells = row.Trim().Split(TAB, 100, StringSplitOptions.RemoveEmptyEntries).ToList();
                foreach (string cell in cells)
                {
                    if (rowCount == 1)
                    {
                        tableOut.Append(HEADING + cell.Trim() + EHEADING);
                    }
                    else
                    {
                        tableOut.Append(CELL + cell.Trim() + ECELL);
                    }
                }
                tableOut.Append(EROW);
                rowCount++;
            }
            tableOut.Append(ETABLE);

            return(tableOut.ToString());
        }