Beispiel #1
0
 }                                                          //TODO: Get this from the Assembly...
 public void LogMessage(string Message)
 {
     using (var context = new TCContext())
     {
         context.LogMessage(ModuleName, Message);
     }
 }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, TCContext db)
        {
            app.UseCors("CorsPolicy");

            //app.UseCors(builder =>
            //    builder.AllowAnyOrigin()
            //           .AllowAnyHeader()
            //           .AllowAnyMethod()
            //    );

            app.UseResponseCompression();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "TravelConnect API V1");
            });

            db.EnsureSeedData();
        }
Beispiel #3
0
        //protected static void LogMessage(string Milestone, string Message)
        //{
        //    using (var context = new TCContext())
        //    {
        //        context.LogMessage(Milestone, Message);
        //    }
        //}
        // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
        // To create an operation that returns XML,
        //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
        //     and include the following line in the operation body:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
        public DataTables <Book> GetData(int pageSize, int page, string search)
        {
            DataTables <Book> result = new DataTables <Book>();

            try
            {
                //string search = ((string)HttpContext.Current.Request.Params["search[value]"]).Trim();
                //string draw = HttpContext.Current.Request.Params["draw"];
                //string order = HttpContext.Current.Request.Params["order[0][column]"];
                //string orderDir = HttpContext.Current.Request.Params["order[0][dir]"];
                //int startRec = Convert.ToInt32(HttpContext.Current.Request.Params["start"]);
                //int pageSize = Convert.ToInt32(HttpContext.Current.Request.Params["length"]);
                // Loading.
                LogMessage("Reading data...");
                var context             = new TCContext();
                IQueryable <Book> query = context.Books.AsNoTracking();
                int totalRecords        = query.Count(); // Total record count.
                // Verification.
                if (!string.IsNullOrEmpty(search) && !string.IsNullOrWhiteSpace(search))
                {   // Apply search
                    query = query.Where(b => b.AlphaSort.Contains(search) ||
                                        b.Title.Contains(search) ||
                                        b.Author.Contains(search) ||
                                        b.MediaFormat.Contains(search) ||
                                        b.ISBN.Contains(search) ||
                                        b.Location.Name.Contains(search)
                                        );
                }
                query = query.OrderBy(b => b.AlphaSort);
                // Sorting.
                //query = SortByColumnWithOrder(order, orderDir, query);
                // Filter record count.
                int filteredRecords = query.Count();
                // Apply pagination.
                //int page = (startRec + pageSize) / pageSize;
                int startRec = page * pageSize;
                result.Data = query.Skip(startRec).Take(pageSize).ToList();
                LogMessage($"Read {result.Data.Count:#,##0} (page #{page:#,##0}) of {(filteredRecords == totalRecords ? $"{totalRecords:#,##0}" : $"{filteredRecords:#,##0} filtered ({totalRecords:#,##0} total)")} Books.");
                // Loading drop down lists.   (??? )
                //result.Draw = Convert.ToInt32(draw);
                result.RecordsTotal    = totalRecords;
                result.RecordsFiltered = filteredRecords;
            }
            catch (Exception ex)
            {
                LogMessage(ex.Message);
            }
            //WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
            return(result);
        }
Beispiel #4
0
 private static void SimpleDecalDemo()
 {
     using (var context = new TCContext())
     {
         StashRepository <Decal> repo = new StashRepository <Decal>(context);
         Decal decal = (Decal)repo.FindByKeyWithImages(Guid.Parse("3e206a4d-4f27-e911-9c25-001583f52824"));
         //Debug.WriteLine("[Before] Decals.ID #{0}: Reference:=\"{1}\"", decal.ID, decal.Reference);
         //Debug.WriteLine("[Before] Images.ID #{0}: FileName:=\"{1}\"", decal.Images[0].ID, decal.Images[0].FileName);
         decal.Reference = decal.Reference == "FTD72003" ? "FTD72003 Data changed" : "FTD72003";
         //Debug.WriteLine("[After] Decals.ID #{0}: Reference:=\"{1}\"", decal.ID, decal.Reference);
         //decal.Images[0].FileName = decal.Images[0].FileName == null ? "Unknown" : null;
         //Debug.WriteLine("[After] Images.ID #{0}: FileName:=\"{1}\"", decal.Images[0].ID, decal.Images[0].FileName);
         //repo.UpdateDisconnected(decal);   //Will update but will not know original values for History updates...
         context.SaveChanges();
     }
 }
Beispiel #5
0
        private static void SimpleBookGraphQuery()
        {
            using (var context = new TCContext())
            {
                Book book = context.Books
                            .Include(b => b.Location) //Eager Loading
                            .FirstOrDefault(b => b.Title.StartsWith("ABC"));

                //If Location is declared as Virtual EF would load the collection
                //on a lazy basis without explicitly loading...
                Book anotherBook = context.Books
                                   .Include(b => b.Location) //Eager Loading
                                   .FirstOrDefault(b => b.Title.StartsWith("Death"));
                //context.Entry(anotherBook).Collection(b => b.Location).Load();
            }
        }
 public string Create(string dbCOntext = "No DB Name Provided")
 {
     TCContext db = new TCContext(dbCOntext);
     db.Users.Add(new Models.User() {
         UserName="******",
         Password="******",
         UserRole="Admin"
     });
     db.Users.Add(new Models.User()
     {
         UserName = "******",
         Password = "******",
         UserRole = "Consultant"
     });
     db.SaveChanges();
     return dbCOntext;
 }
        public ActionResult Login(LoginViewModel model)
        {
            List<Tenant> tenants = new List<Tenant>();
            tenants.Add(new Tenant() { Id = 1, Name = "K Force", DbContext = "KforceDB", Email = "*****@*****.**" });
            tenants.Add(new Tenant() { Id = 2, Name = "Sudeep Company", DbContext = "SudeepDB", Email = "*****@*****.**" });
            string dbCOntext = tenants.Single(x => x.Id == model.TenantId).DbContext;

            TCContext db = new TCContext(dbCOntext);

            User user = db.Users.SingleOrDefault(x => x.UserName == model.UserName);
            if (user != null)
            {
                FormsAuthentication.Initialize();
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                    user.UserName,
                    DateTime.Now,
                    DateTime.Now.AddMinutes(30), // value of time out property
                    model.IsRemember, // Value of IsPersistent property
                    user.UserRole,
                    FormsAuthentication.FormsCookiePath);

                string encryptedTicket = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                if (ticket.IsPersistent)
                {
                    cookie.Expires = ticket.Expiration;
                }
                Response.Cookies.Add(cookie);
                return RedirectToAction("Index", "Home");
            }

            ViewData["Tenants"] = (from t in tenants
                                   select new SelectListItem()
                                   {
                                       Text = t.Name,
                                       Value = t.Id.ToString()
                                   }).ToList();

            return View(model);
        }
Beispiel #8
0
        private static void InsertDecalDemo()
        {
            using (var context = new TCContext())
            {
                var decal = new Decal
                {
                    //ID = AutoIncrement,
                    OID = 35,
                    //RowID = Null,
                    //DateCreated = Null,
                    //DateModified = Null,
                    Cataloged       = true,
                    DateInventoried = new DateTime(2005, 9, 5, 16, 5, 29),
                    DatePurchased   = new DateTime(2005, 9, 5, 16, 5, 28),
                    DateVerified    = new DateTime(2005, 9, 6, 17, 6, 39),
                    Location        = context.Locations.Find(2),
                    Notes           = "",
                    Price           = 0,
                    Value           = 0,
                    WishList        = false,
                    Designation     = "UNKNOWN",
                    Manufacturer    = "Monogram",
                    Name            = "Rommel's Rod™ - Tom Daniel",
                    Nation          = "N/A",
                    ProductCatalog  = "HobbyTown USA",
                    Reference       = "85-4260",
                    Scale           = "1/24",
                    Type            = "Car"
                };
                context.Add(decal);
                context.SaveChanges();
                //decal = context.Decals.Find(1);

                decal = context.Decals.Where(d => d.ID == Guid.Parse("3e206a4d-4f27-e911-9c25-001583f52824")).Include(d => d.Location).FirstOrDefault();
            }
        }
 public UserRepository(TCContext context, IMapper mapper) : base(context, mapper)
 {
 }
 public CommitmentRepository(TCContext tCContext, IMapper mapper) : base(tCContext, mapper)
 {
 }
Beispiel #11
0
 public SabreCredentialsController(TCContext context)
 {
     _context = context;
 }
 public QuestionnaireRepository(TCContext Context, IMapper Mapper) : base(Context, Mapper)
 {
 }
Beispiel #13
0
 public AssignmentRepository(TCContext Context, IMapper Mapper) : base(Context, Mapper)
 {
 }
Beispiel #14
0
 public StashRepository(TCContext context)
 {
     _context = context;
     InitContextStuff();
 }
Beispiel #15
0
 public StashRepository()
 {
     _context = new TCContext();
     InitContextStuff();
 }
Beispiel #16
0
 public SabreConnector(TCContext _context)
 {
     this._context = _context;
 }
 public BaseRepository(TCContext Context, IMapper Mapper)
 {
     _Context = Context;
     _Mapper  = Mapper;
 }
Beispiel #18
0
 public CourseRepository(TCContext tCContext, IMapper mapper) : base(tCContext, mapper)
 {
 }