[HttpPut("customer/{id}")] /*updates a specific customer*/ public ReturnData <Customer> UpdateCustomer([FromRoute] int id , [FromBody] CustomerDto customerDto) { MyServices services = new MyServices(); return(services.UpDateCustomer(customerDto, id)); }
[HttpGet("customer/{id}/order/{orderid}")]// gets a specific orders of a customer public ReturnData <Order> GetOrderByCustomerIdAndByOrderId([FromRoute] int id , [FromRoute] int orderid) { MyServices services = new MyServices(); return(services.GetOrderByCustomerIdAndByOrderId(id, orderid)); }
public ReturnData <List <Product> > CreatListOfProductsByOrder([FromRoute] int id , [FromBody] List <ProductDtos> productDtos) { MyServices services = new MyServices(); return(services.CreateListOfProductsByOrder(id, productDtos)); }
static void test1() { MyServices myServices = new MyServices(); myServices.Read(2); if (myServices.Customer != null) { Console.WriteLine( $"Id= {myServices.Customer.Id} name= {myServices.Customer.Name}"); } else { Console.WriteLine("no such customer"); } myServices.Delete(20); CustomerDto customerDto = new CustomerDto { Address = "Arta" }; myServices.Update(customerDto, 1); myServices.Read(1); Console.WriteLine( $"Id= {myServices.Customer.Id} " + $"name= {myServices.Customer.Name} " + $"address= {myServices.Customer.Address}"); }
public IMyServices CreateSampleService() { IMyServices service = new MyServices(); service.Service_Id = "1"; service.Name = "sampleName"; return(service); }
public int AddService(MyServices model) { string query = @"Insert into MyServices(MemberId,ServiceId,StartDate,ValidDate,Status,IsPaid,PaymentConfirmed) values(@MemberId,@ServiceId,@StartDate,@ValidDate,@Status,@IsPaid,@PaymentConfirmed); SELECT @@IDENTITY"; int insertedId = db.Connection.Query <int>(query, new { MemberId = model.MemberId, ServiceId = model.ServiceId, StartDate = model.StartDate, ValidDate = model.ValidDate, Status = model.Status, IsPaid = model.IsPaid, PaymentConfirmed = model.PaymentConfirmed }).Single(); return(insertedId); }
public ActionResult Create(MyServices model) { if (model.Id == 0) // { Service requestedService = this._serviceRepo.GetServiceById(model.ServiceId); model.MemberId = this._userTable.GetmemberId(User.Identity.Name); model.Status = "InActive"; // InActive untill payment not done. model.IsPaid = false; model.PaymentConfirmed = false; if (requestedService.ServiceType.ToUpper() == "MONTHLY") { model.ValidDate = model.StartDate.AddMonths(1); int memberServiceId = this._mySubscriptionRepo.AddService(model); var items = new List <SubscriptionItemOption> { new SubscriptionItemOption { PlanId = requestedService.StripePlanName } }; var options = new SubscriptionCreateOptions { CustomerId = model.StripeCustomerId,// "cus_ExQd0tzJcBzqlw", Items = items, Metadata = new Dictionary <string, string>() { { "MemberServiceId", memberServiceId.ToString() }, { "PaymentUrl", "/Payment/Index?myserviceid=" + memberServiceId.ToString() }, } }; var service = new SubscriptionService(); Subscription subscription = service.Create(options); this._mySubscriptionRepo.UpdateSubscriptionStatus(memberServiceId, model.StripeCustomerId, subscription.Id); return(RedirectToAction("Index", "Subscriptions")); } else { model.ValidDate = model.StartDate.AddYears(50); // no need but value cannot be null so. int memberServiceId = this._mySubscriptionRepo.AddService(model); return(RedirectToAction("Index", "Payment", new { myserviceid = memberServiceId })); } } else { } var serviceList = this._serviceRepo.GetServiceList(); ViewBag.ServiceList = new SelectList(serviceList, "Id", "Name", model.ServiceId); return(View(model)); }
private void AddReferencedVariable(MemberElement previous) { if ((previous != null)) { return; } if ((_myVariableType != null) || MyOptions.IsOwnerType(this.MemberOwnerType) == true) { ExpressionInfo info = (ExpressionInfo)MyServices.GetService(typeof(ExpressionInfo)); info.AddReferencedVariable(MyName); } }
/// <summary> /// Application specific configuration /// This method should initialize any IoC resources utilized by your web service classes. /// </summary> /// <param name="container"></param> public override void Configure(Container container) { SetConfig(new HostConfig { DebugMode = true }); //Config examples Plugins.Add(new PostmanFeature()); Plugins.Add(new CorsFeature()); Plugins.Add(new AuthFeature(() => new CustomUserSession(), new IAuthProvider[] { new BasicAuthProvider(AppSettings), new CredentialsAuthProvider(AppSettings), }) { IncludeRegistrationService = true, HtmlRedirect = "/", }); container.Register <IRedisClientsManager>(c => new PooledRedisClientManager("localhost:6379")); container.Register(c => c.Resolve <IRedisClientsManager>().GetCacheClient()); container.Register <IDbConnectionFactory>(c => new OrmLiteConnectionFactory( AppSettings.GetString("AppDb"), PostgreSqlDialect.Provider)); container.Register <IAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve <IDbConnectionFactory>()) { UseDistinctRoleTables = AppSettings.Get("UseDistinctRoleTables", true), }); var authRepo = (OrmLiteAuthRepository)container.Resolve <IAuthRepository>(); MyServices.ResetUsers(authRepo); }
public ActionResult Create(int?Id) { MyServices subscription = new MyServices(); subscription.StartDate = DateTime.Today; subscription.ValidDate = DateTime.Today.AddMonths(1); if (Id.HasValue) { subscription = this._mySubscriptionRepo.FindServiceById(Id); } //var serviceList = this._serviceRepo.GetServiceList(); int member = this._userTable.GetmemberId(User.Identity.Name); var serviceList = this._serviceRepo.GetAppliedServiceList(member); // filtering the service list according to service taken by member. ViewBag.ServiceList = new SelectList(serviceList, "Id", "Name", subscription.ServiceId); bool isInstallationActive = this._mySubscriptionRepo.CheckIfInstallationActive(member); ViewBag.isInstallationActive = isInstallationActive; ViewBag.IsMemberService = serviceList.Where(a => !a.Name.Contains("Installation")).Count() == 1 ? true : false; string membersStripeCustomerId = this._mySubscriptionRepo.FindMembersStripeCustomerId(member); subscription.StripeCustomerId = membersStripeCustomerId; return(View(subscription)); }
[HttpGet("customers")]/*//returns all of the customers*/ public List <Customer> Customers() { MyServices services = new MyServices(); return(services.GetCustomers(3)); }
public ReturnData <List <Customer> > GetCustomerByName([FromRoute] string name) { MyServices services = new MyServices(); return(services.GetCustomerByName(name)); }
[HttpPost("product")]//creats product public ReturnData <Product> CreateProduct([FromBody] ProductDtos productDtos) { MyServices services = new MyServices(); return(services.CreateProduct(productDtos)); }
[HttpGet("products")]//gets the list of the first 3 products public ReturnData <List <Product> > GetProduct() { MyServices services = new MyServices(); return(services.GetProducts(3)); }
public ReturnData <List <Order> > GetOrdersByCustomerId([FromRoute] int id) { MyServices services = new MyServices(); return(services.GetOrdersByCustomerId(id)); }
[HttpGet("orders")]/*//returns all of the orders*/ public List <Order> Orders() { MyServices services = new MyServices(); return(services.GetOrders(12)); }
[HttpPost("order")]//creates an order public Order CreateNewOrder([FromBody] OrderDto orderDto) { MyServices services = new MyServices(); return(services.CreateOrder(orderDto)); }
[HttpPost("customer")]//creates a customer public Customer CreateNewCustomer([FromBody] CustomerDto customerDto) { MyServices services = new MyServices(); return(services.CreateCustomer(customerDto)); }
// basic sync for db items .. NOTE uses dummy items at the moment for debugging public async void SyncAPiToDB() { // get db connection DbAccessor db = new DbAccessor(); db.CreateTable <Models.Company.MyCompany>(); // company users var usersdb = db.GetTableItems <CompanyUser>(); if (usersdb != null && usersdb.Count == 0) { var prgApi = DummyEmpData.GetCompanyUsers(); // store in db as CompanyUserDetails in json foreach (var pg in prgApi) { CompanyUser item = new CompanyUser { UserId = pg.UserId, UserRole = pg.AssignedRole, JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <CompanyUser>(item); } } // company details var companydb = db.GetTableItems <CompanyProfile>(); if (companydb != null && companydb.Count == 0) { var comp = DummyEmpData.GetCompanyDetails(); // store in db as CompanyProfile in json CompanyProfile item = new CompanyProfile { ProfileId = comp.CompanyId, JSON = JsonConvert.SerializeObject(comp) }; db.InsertRecord <CompanyProfile>(item); } // employer posted jobs var empdb = db.GetTableItems <EmployerJobs>(); if (empdb != null && empdb.Count == 0) { var prgApi = DummyEmpData.GetEmployerPostedJobs(); // store in db as EmployerJobs in json foreach (var pg in prgApi) { var item = new EmployerJobs { JobPostId = pg.JobPostId, Status = pg.Status, JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <EmployerJobs>(item); } } // current assigned programs for company var myProgdb = db.GetTableItems <MyPrograms>(); if (myProgdb != null && myProgdb.Count == 0) { var prgApi = DummyEmpData.GetCurrentPrograms(); // store in db as EmployerProgram in json foreach (var pg in prgApi) { var item = new MyPrograms { ProgramId = pg.ProgramId, JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <MyPrograms>(item); } } // add all programs var allProgdb = db.GetTableItems <DBAccess.Programs>(); if (allProgdb != null && allProgdb.Count == 0) { var prgApi = DummyEmpData.GetAllPrograms(); // store in db as EmployerProgram in json foreach (var pg in prgApi) { var item = new DBAccess.Programs { ProgramId = pg.ProgramId, JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <DBAccess.Programs>(item); } } // current assigned employer services // save as EmployerService var servdb = db.GetTableItems <MyServices>(); if (servdb != null && servdb.Count == 0) { var prgApi = DummyEmpData.GetEmployerServices(); // store in db as MyServices in json foreach (var pg in prgApi) { var item = new MyServices { ServiceId = pg.ServiceId, JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <MyServices>(item); } } // all services var allservdb = db.GetTableItems <AllServices>(); if (allservdb != null && allservdb.Count == 0) { var prgApi = DummyEmpData.GetALLServices(); // store in db as AllServices in json foreach (var pg in prgApi) { var item = new AllServices { ServiceId = pg.ServiceId, JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <AllServices>(item); } } // announcements var anndb = db.GetTableItems <Announcement>(); if (anndb != null && anndb.Count == 0) { var prgApi = DummyEmpData.GetAnnouncements(); foreach (var pg in prgApi) { try { db.InsertRecord <Announcement>(new Announcement { CompanyName = pg.CompanyName, Description = pg.Description, Featured = false, Image = "", Ttle = pg.Ttle, Url = pg.Url }); } catch (Exception ex) { Debug.WriteLine("ERROR:" + ex.Message); } } } // job applicants list var jobappdb = db.GetTableItems <JobApplicant>(); if (jobappdb != null && jobappdb.Count == 0) { var prgApi = DummyEmpData.GetCompanyJobApplications(); // store ApplicationProfile as json foreach (var pg in prgApi) { var item = new JobApplicant { ApplicantId = pg.ApplicationId.ToString(), JobPostId = pg.JobPostId.ToString(), JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <JobApplicant>(item); } } // search applicants var matcheddb = db.GetTableItems <MatchedClients>(); if (matcheddb != null && matcheddb.Count == 0) { var prgApi = DummyEmpData.GetCompanyJobApplications(); // store ApplicationProfile as json foreach (var pg in prgApi) { var item = new MatchedClients { ProfileId = pg.ApplicationId.ToString(), JobPostId = pg.JobPostId.ToString(), JSON = JsonConvert.SerializeObject(pg) }; db.InsertRecord <MatchedClients>(item); } } // event data we need // add in any events from dummy data var eventsDb = db.GetTableItems <EventDetails>(); if (eventsDb != null && eventsDb.Count == 0) { var eventList = DummyEmpData.GetEventsList(); foreach (var itemEv in eventList) { // new item so add it in :) EventDetails item = new EventDetails { EventId = itemEv.EventId, EventEnd = itemEv.EventEnd, EventLocation = itemEv.EventLocation, EventStart = itemEv.EventStart, EventTitle = itemEv.EventTitle, Status = itemEv.Status, AdditionalInfo = itemEv.AdditionalInfo, Email = itemEv.Email, PhoneNumber = itemEv.PhoneNumber, JobPostId = itemEv.JobPostId }; db.InsertRecord <EventDetails>(item); } } // insert dummy compaints data var ComplaintsDb = db.GetTableItems <ComplaintRaised>(); if (ComplaintsDb != null && ComplaintsDb.Count == 0) { // fill with new data var compaintsData = DummyEmpData.GetComplaintsList(); foreach (var itemEv in compaintsData) { db.InsertRecord <ComplaintRaised>(new ComplaintRaised { ComplaintText = itemEv.ComplaintText, ComplaintId = itemEv.ComplaintId, Subject = itemEv.Subject, Status = itemEv.Status, CreatedOn = itemEv.CreatedOn, ClosedOn = itemEv.ClosedOn, Category = itemEv.Category }); } } }
[HttpGet("product/{id}")]//get product by id public ReturnData <Product> GetProductById([FromRoute] int id) { MyServices services = new MyServices(); return(services.GetProductById(id)); }
public ReturnData <List <Product> > GetProductByName([FromRoute] string name) { MyServices services = new MyServices(); return(services.GetProductByName(name)); }
// HttpContextAccessor httpContextAccessor, public TestController(MyServices _services) { services = _services; //_httpContextAccessor = httpContextAccessor; }
[HttpGet("customers/{id}")]/*// returns the customer with a specific key */ public ReturnData <Customer> CustomerId([FromRoute] int id) { MyServices services = new MyServices(); return(services.GetCustomerId(id)); }