public static long Insert(Refill refill) { using (var db = DatabaseService.Connection) { Dapper.SqlMapper.SetTypeMap(typeof(Refill), new ColumnAttributeTypeMapper <Refill>()); return(db.Query <long>(ScriptService.Scripts["refill_insert"], refill).Single()); } }
public dynamic RemoveSubscription(SubscriptionDetails obj, string Token) { string data = JsonConvert.SerializeObject(obj); Uri baseAddress = new Uri("https://refillservice856709.azurewebsites.net/api"); HttpClient client = new HttpClient(); client.BaseAddress = baseAddress; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/Refill/RefillStatus/" + obj.Sub_id).Result; if (response.IsSuccessStatusCode) { data = response.Content.ReadAsStringAsync().Result; Refill refill = JsonConvert.DeserializeObject <Refill>(data); if (refill.Status == "clear") { ls.Remove(obj); return("Unsubscription Done. Thank You!"); } return("Sorry!Clear The Dues Before Unsubscription"); } return(null); }
public static void UpdateInactive(Refill refill) { using (var db = DatabaseService.Connection) { Dapper.SqlMapper.SetTypeMap(typeof(Refill), new ColumnAttributeTypeMapper <Refill>()); db.Execute(ScriptService.Scripts["refill_update_inactive"], refill); } }
private static void RefillOnPlayer(On.Celeste.Refill.orig_OnPlayer orig, Refill self, Player player) { if (self.GetType() == typeof(ColorfulRefill)) { new DynData <Player>(player)["DJMapHelper_RefillColor"] = ((ColorfulRefill)self).color; } orig(self, player); }
public ActionResult SetFilled(long id) { Refill r = DatabaseRefillService.GetById(id); r.SetFilled(); DatabaseRefillService.Update(r); return(RedirectToAction("RefillListView", "Pharmacy")); }
public ActionResult DeleteRefill(long id) { Refill r = DatabaseRefillService.GetById(id); r.RefillIt = false; DatabaseRefillService.Update(r); return(RefillListView()); }
public async Task <IActionResult> Create([Bind("RefillId,RequestDate,PickupStatus")] Refill refill) { //create a new prescription based off the information selected. send that object to the refills list and display message stating refill has ben sent if (ModelState.IsValid) { _context.Add(refill); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(refill)); }
//Sends test emails with working callbacks to the email specified public string SendTestEmail() { var u = new User(); var p = new Patient(); var n = new Notification(); var pr = new Prescription(); var r = new Refill(); u.Email = "*****@*****.**"; // PUT YOUR EMAIL HERE TO TEST u.FirstName = "Test"; u.LastName = "User"; u.Phone = "+14055555555"; u.UserId = DatabaseUserService.Insert(u); p.UserId = u.UserId; p.PharmacyId = 1; p.DateOfBirth = DateTime.Now; p.PreferedContactTime = DateTime.Now; p.ContactMethod = Patient.PrimaryContactMethod.Email; p.PersonCode = "0"; p.SendBirthdayMessage = true; p.SendRefillMessage = true; p.PatientId = DatabasePatientService.Insert(p); pr.PatientId = p.PatientId; pr.PrescriptionDaysSupply = 30; pr.PrescriptionRefills = 3; pr.PrescriptionName = "Tylenol"; pr.PrescriptionNumber = 1; pr.PrescriptionUpc = "ABC123"; pr.PrescriptionDateFilled = DateTime.Now; pr.PrescriptionId = DatabasePrescriptionService.Insert(pr); r.RefillIt = false; r.PrescriptionId = pr.PrescriptionId; r.Refilled = false; r.RefillDate = DateTime.Now; r.RefillId = DatabaseRefillService.Insert(r); n.PatientId = p.PatientId; n.Type = Notification.NotificationType.Refill; n.NotificationMessage = "This is a test email for a refill"; n.ScheduledTime = DateTime.Now; n.SentTime = null; n.Sent = false; n.NotificationId = DatabaseNotificationService.Insert(n); EmailService.SendNotification(n); EmailService.SendReset(u); return("Sent an notification and reset email to test account"); }
public FormOrders(DatabaseContext dbContext, User user, int refillNumber) { InitializeComponent(); this.dbContext = dbContext; this.user = user; dbContext.Refresh(dbContext.Refills); refill = dbContext.Refills.FirstOrDefault(x => x.Number == refillNumber); UpdateGridOrders(dbContext.Orders); FormClosing += FormOrders_FormClosing; dbContext.isRefreshDb += DbContext_isRefreshDb; dbContext.Refresh(dbContext.Refills); }
public static bool SendFilledNotification(Refill refill) { var n = new Notification(refill, Notification.NotificationType.Ready); var p = DatabasePrescriptionService.GetById(refill.PrescriptionId); n.PatientId = p.PatientId; System.Diagnostics.Debug.WriteLine(n.PatientId); n.NotificationId = DatabaseNotificationService.Insert(n); var pat = Patient.PatientDict[n.PatientId]; var twilio = new TwilioApi(pat.getPharmacy()); SendNotification(n, twilio); return(true); }
public void SetClosed(Refill refill) { var refillUpdate = refill.Id > 0 ? GetById(refill.Id) : new Refill(); if (!(refill.Id > 0)) { return; } var refillDa = new RefillDa(databasecontext); refillUpdate.Closed = true; refillDa.Update(refillUpdate); }
public string AddFakePresRefillNotif(long pid) { var pres = new Prescription { PatientId = pid, PrescriptionName = "Test Prescription", PrescriptionNumber = 12345, PrescriptionRefills = 3, PrescriptionDateFilled = System.DateTime.Now.AddDays(-27), PrescriptionDaysSupply = 30, PrescriptionUpc = "123456789" }; pres.PrescriptionId = DatabasePrescriptionService.Insert(pres); var refill = new Refill(pres); refill.RefillIt = false; refill.RefillId = DatabaseRefillService.Insert(refill); return("Sucesss"); }
public ActionResult AdhocDrug_Refill(RefillOrder ad) { string Token = HttpContext.Request.Cookies["Token"]; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); string data = JsonConvert.SerializeObject(ad); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/Refill/requestAdhocRefill/", content).Result; if (response.IsSuccessStatusCode) { string scheduleData = response.Content.ReadAsStringAsync().Result; Refill r = JsonConvert.DeserializeObject <Refill>(scheduleData); return(View("AdhocRefill", r)); } return(View()); }
private async void AddMoney_Click(object sender, EventArgs e) { if (moneyCountAdd.Text == String.Empty) { MessageBox.Show("Введите количество денег для пополнения", "Недопустимое значение", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int addMoneyCount = Int32.Parse(moneyCountAdd.Text); moneyCountAdd.Text = ""; var refill = new Refill() { Sum = addMoneyCount, Balance = addMoneyCount, Date = DateTime.Now }; dbContext.Refills.Add(refill); await dbContext.SaveChangesAsync(); UpdateGridRefill(dbContext.Refills); }
public ActionResult View_RefillDetails(Refill refill) { string Token = HttpContext.Request.Cookies["Token"]; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/Refill/RefillStatus/" + refill.Subscription_ID).Result; if (response.IsSuccessStatusCode) { string scheduleData = response.Content.ReadAsStringAsync().Result; Refill r = JsonConvert.DeserializeObject <Refill>(scheduleData); context.RefillDetails.Add(r); context.SaveChanges(); return(View("RefillStatus", r)); } return(View()); }
public ActionResult View_RefillDues(Refill obj) { string Token = HttpContext.Request.Cookies["Token"]; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token); int Subid = obj.Subscription_ID; string sdate = obj.FromDate.ToString("yyyy-MM-dd"); HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/Refill/RefillDueAsOfDate/" + Subid + "/" + sdate).Result; if (response.IsSuccessStatusCode) { string scheduleData = response.Content.ReadAsStringAsync().Result; IEnumerable <Refill> r = JsonConvert.DeserializeObject <List <Refill> >(scheduleData); return(View("RefillDues", r)); } return(View()); }
public ActionResult RemoveSubscription(SubscriptionDetails obj) { string data = JsonConvert.SerializeObject(obj); int x = obj.Sub_id; Uri baseAddress = new Uri("https://localhost:44322/api"); HttpClient client = new HttpClient(); client.BaseAddress = baseAddress; HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/Refill/" + x).Result; if (response.IsSuccessStatusCode) { data = response.Content.ReadAsStringAsync().Result; Refill refill = JsonConvert.DeserializeObject <Refill>(data); if (refill.Status == "clear") { ls.Remove(obj); return(Ok("done")); } return(BadRequest("Clear the Dues")); } return(BadRequest()); }
public DesignDataService() { _clients = new List <Client>(); _refills = new List <Refill>(); Client c = new Client() { ClientID = 1, Accounts = null, FirstName = "Nazar", LastName = "Matus", MiddleName = "Vovich", Password = "******", Phone = "0987655432", Username = "******" }; _clients.Add(c); Account a = new Account() { AccountID = 1, Client = c, ClientID = c.ClientID, Cash = 20, DebtCeiling = 0 }; Refill r = new Refill() { RefillID = 228, AccountID = a.AccountID, RefillTime = DateTime.Now, Cash = 100, Account = a }; _refills.Add(r); }
public void Delete(Refill refill) { _databasecontext.Refills.Remove(refill); _databasecontext.SaveChanges(); }
public Refill Update(Refill refill) { _databasecontext.SaveChanges(); return(refill); }
public Refill Add(Refill refill) { _databasecontext.Refills.Add(refill); _databasecontext.SaveChanges(); return(refill); }
private void OverlayEntities(MapElement entities, Bitmap map, VirtualMap <char> solids, bool background) { CassetteBlock.Blocks.Clear(); using (Graphics g = Graphics.FromImage(map)) { List <Entity> ents = new List <Entity>(); for (int i = entities.Children.Count - 1; i >= 0; i--) { MapElement child = entities.Children[i]; Entity entity = null; if (child.Name.IndexOf("spikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Spikes.FromElement(child) : null; } else if (child.Name.IndexOf("triggerSpikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? TriggerSpikes.FromElement(child) : null; } else if (child.Name.IndexOf("strawberry", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("goldenBerry", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("redBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("greenBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("yellowBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("clutterCabinet", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterCabinet.FromElement(child) : null; } else if (child.Name.Equals("introCar", StringComparison.OrdinalIgnoreCase)) { entity = background ? IntroCar.FromElement(child) : null; } else if (child.Name.Equals("clothesLine", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClothesLine.FromElement(child) : null; } else if (child.Name.Equals("colorSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? ColorSwitch.FromElement(child) : null; } else if (child.Name.Equals("memorialTextController", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("bonfire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bonfire.FromElement(child) : null; } else if (child.Name.Equals("trapDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrapDoor.FromElement(child) : null; } else if (child.Name.Equals("movingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? MovingPlatform.FromElement(child) : null; } else if (child.Name.Equals("sinkingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? SinkingPlatform.FromElement(child) : null; } else if (child.Name.Equals("clutterDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterDoor.FromElement(child) : null; } else if (child.Name.Equals("bridge", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bridge.FromElement(child) : null; } else if (child.Name.Equals("bridgeFixed", StringComparison.OrdinalIgnoreCase)) { entity = background ? BridgeFixed.FromElement(child) : null; } else if (child.Name.Equals("jumpThru", StringComparison.OrdinalIgnoreCase)) { entity = background ? JumpThru.FromElement(child) : null; } else if (child.Name.Equals("door", StringComparison.OrdinalIgnoreCase)) { entity = background ? Door.FromElement(child) : null; } else if (child.Name.Equals("blockField", StringComparison.OrdinalIgnoreCase)) { entity = background ? BlockField.FromElement(child) : null; } else if (child.Name.Equals("lamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? Lamp.FromElement(child) : null; } else if (child.Name.Equals("hahaha", StringComparison.OrdinalIgnoreCase)) { entity = background ? Haha.FromElement(child) : null; } else if (child.Name.Equals("waterFall", StringComparison.OrdinalIgnoreCase)) { entity = background ? WaterFall.FromElement(child) : null; } else if (child.Name.Equals("water", StringComparison.OrdinalIgnoreCase)) { entity = background ? Water.FromElement(child) : null; } else if (child.Name.Equals("key", StringComparison.OrdinalIgnoreCase)) { entity = background ? Key.FromElement(child) : null; } else if (child.Name.Equals("resortLantern", StringComparison.OrdinalIgnoreCase)) { entity = background ? ResortLantern.FromElement(child) : null; } else if (child.Name.Equals("bird", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bird.FromElement(child) : null; } else if (child.Name.Equals("memorial", StringComparison.OrdinalIgnoreCase)) { entity = background ? Memorial.FromElement(child) : null; } else if (child.Name.Equals("player", StringComparison.OrdinalIgnoreCase)) { entity = background ? PlayerSpawn.FromElement(child) : null; } else if (child.Name.Equals("zipMover", StringComparison.OrdinalIgnoreCase)) { entity = background ? ZipMover.FromElement(child) : null; } else if (child.Name.Equals("wire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Wire.FromElement(child) : null; } else if (child.Name.Equals("crumbleBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CrumbleBlock.FromElement(child) : null; } else if (child.Name.Equals("refill", StringComparison.OrdinalIgnoreCase)) { entity = background ? Refill.FromElement(child) : null; } else if (child.Name.Equals("spring", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spring.FromElement(child) : null; } else if (child.Name.Equals("fakeWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("exitBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("lightBeam", StringComparison.OrdinalIgnoreCase)) { entity = background ? LightBeam.FromElement(child) : null; } else if (child.Name.Equals("cobweb", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cobweb.FromElement(child) : null; } else if (child.Name.Equals("cassette", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cassette.FromElement(child) : null; } else if (child.Name.Equals("flutterBird", StringComparison.OrdinalIgnoreCase)) { entity = background ? FlutterBird.FromElement(child) : null; } else if (child.Name.Equals("checkpoint", StringComparison.OrdinalIgnoreCase)) { entity = background ? Checkpoint.FromElement(child) : null; } else if (child.Name.Equals("fallingBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("introCrusher", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("cassetteBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CassetteBlock.FromElement(child) : null; } else if (child.Name.Equals("dashBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DashBlock.FromElement(child) : null; } else if (child.Name.Equals("coverupWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? CoverupWall.FromElement(child) : null; } else if (child.Name.Equals("npc", StringComparison.OrdinalIgnoreCase)) { entity = background ? NPC.FromElement(child) : null; } else if (child.Name.Equals("birdForsakenCityGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? ForsakenCityGem.FromElement(child) : null; } else if (child.Name.Equals("soundSource", StringComparison.OrdinalIgnoreCase)) { entity = background ? SoundSource.FromElement(child) : null; } else if (child.Name.Equals("friendlyGhost", StringComparison.OrdinalIgnoreCase)) { entity = background ? FriendlyGhost.FromElement(child) : null; } else if (child.Name.Equals("floatingDebris", StringComparison.OrdinalIgnoreCase)) { entity = background ? FloatingDebris.FromElement(child) : null; } else if (child.Name.Equals("hangingLamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? HangingLamp.FromElement(child) : null; } else if (child.Name.Equals("lockBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? LockBlock.FromElement(child) : null; } else if (child.Name.Equals("heartGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("blackGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("dreamMirror", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamMirror.FromElement(child) : null; } else if (child.Name.Equals("darkChaser", StringComparison.OrdinalIgnoreCase)) { entity = background ? DarkChaser.FromElement(child) : null; } else if (child.Name.Equals("dreamBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamBlock.FromElement(child) : null; } else if (child.Name.Equals("touchSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? TouchSwitch.FromElement(child) : null; } else if (child.Name.Equals("switchGate", StringComparison.OrdinalIgnoreCase)) { entity = background ? SwitchGate.FromElement(child) : null; } else if (child.Name.Equals("invisibleBarrier", StringComparison.OrdinalIgnoreCase)) { entity = background ? InvisibleBarrier.FromElement(child) : null; } else if (child.Name.Equals("payphone", StringComparison.OrdinalIgnoreCase)) { entity = background ? Payphone.FromElement(child) : null; } else if (child.Name.Equals("spinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spinner.FromElement(child) : null; } else if (child.Name.Equals("rotateSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? RotateSpinner.FromElement(child) : null; } else if (child.Name.Equals("trackSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrackSpinner.FromElement(child) : null; } else if (child.Name.Equals("towerViewer", StringComparison.OrdinalIgnoreCase)) { entity = background ? TowerViewer.FromElement(child) : null; } else if (child.Name.Equals("foregroundDebris", StringComparison.OrdinalIgnoreCase)) { entity = !background?ForegroundDebris.FromElement(child) : null; } else if (background) { Console.WriteLine(child.Name); } if (entity != null) { ents.Add(entity); } } ents.Sort(delegate(Entity one, Entity two) { int comp = two.Depth.CompareTo(one.Depth); return(comp == 0 ? one.ID.CompareTo(two.ID) : comp); }); for (int i = 0; i < ents.Count; i++) { Entity entity = ents[i]; entity.Render(g, solids); } } }
/// <summary> /// Initializes a new instance of the RefillViewModel class. /// </summary> //public RefillViewModel(Refill refill) //{ // _refill = refill; // _refill = _dataService.All<Refill>().First(); //} public RefillViewModel(IDataService dataService) //version for design { _dataService = dataService; _refill = _dataService.All <Refill>().First(); }
public IActionResult RefillStatus(Refill obj) { return(View()); }
public static bool ParseCsv(HttpPostedFileBase upload, long pharmacyId) { //Check if valid file was uploaded if (upload != null && upload.ContentLength > 0 && upload.FileName.EndsWith(".csv")) { //Convert binary file received from request into text var textdata = string.Empty; using (BinaryReader b = new BinaryReader(upload.InputStream)) { var binData = b.ReadBytes(upload.ContentLength); textdata = Encoding.UTF8.GetString(binData); } //Get list of patients from database for comparison var patients = new Dictionary <string, Patient>(); var patientlist = DatabasePatientService.GetAll(pharmacyId); foreach (var p in patientlist) { p.LoadUserData(); patients.Add(p.PersonCode, p); } //Interate over each line of text in the file var text = new StringReader(textdata); var line = string.Empty; //Remove headers from file text.ReadLine(); while ((line = text.ReadLine()) != null) { var row = line.Split(','); //Check if patient exists try { var dateNow = DateTime.Now; Patient patient = new Patient() { PersonCode = row[0], FirstName = row[1], LastName = row[2], DateOfBirth = DateTime.ParseExact(row[3], "yyyyMMdd", null), Phone = row[5], Email = row[6], PharmacyId = pharmacyId }; if (patients.ContainsKey(row[0])) { //Update patient var oldPatient = patients[row[0]]; patient.UserId = oldPatient.UserId; patient.PatientId = patients[row[0]].PatientId; patient.Type = oldPatient.Type; patient.UserLogin = oldPatient.UserLogin; patient.ContactMethod = oldPatient.ContactMethod; patient.PreferedContactTime = oldPatient.PreferedContactTime; patient.SendBirthdayMessage = oldPatient.SendBirthdayMessage; patient.SendRefillMessage = oldPatient.SendRefillMessage; DatabaseUserService.Update(patient); DatabasePatientService.Update(patient); DatabaseUserService.Enable(patient.PatientId); DatabasePatientService.Enable(patient.PatientId); } else { //Create patient patient.PreferedContactTime = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 15, 0, 0); patient.UserId = DatabaseUserService.Insert(patient); patient.PatientId = DatabasePatientService.Insert(patient); } //Check if prescription exists try { var prescriptionId = Convert.ToInt32(row[8]); var prescription = new Prescription() { PrescriptionDateFilled = DateTime.ParseExact(row[7], "yyyyMMdd", null), PrescriptionNumber = prescriptionId, PrescriptionId = prescriptionId, PrescriptionDaysSupply = Convert.ToInt32(row[9]), PrescriptionRefills = Convert.ToInt32(row[10]), PrescriptionUpc = row[11], PrescriptionName = row[12], PatientId = patient.PatientId }; DatabasePrescriptionService.InsertOrUpdate(prescription); if (DatabaseRefillService.GetByPrescriptionId(prescription.PrescriptionId) == null) { var refill = new Refill(prescription) { }; DatabaseRefillService.Insert(refill); } } catch (Exception e) { //Ignore prescriptions that fail the model building } } catch (Exception e) { //Do not add patients which fail the model building } } return(true); } return(false); }
public IActionResult AdhocRefill(Refill obj) { return(View()); }
public ActionResult Payment([FromBody] RestRefillment input) { if (!ModelState.IsValid) { return(BadRequest()); } var user = accountService.GetCurrentUserForContext(HttpContext); if (user == null) { return(NotFound()); } // Make sure that all drinks exist if (input.Items.Any(item => !dbcontext.Drink.Any(d => d.Id == item.DrinkId))) { return(NotFound()); } // user should get the money they payed for the refill. user.Balance += input.Price; dbcontext.Update(user); // Create a refill var refill = new Refill { UserId = user.Id, Price = input.Price }; dbcontext.Refill.Add(refill); foreach (var item in input.Items) { // Add new log entry in db var refillContainment = new RefillContainment { RefillId = refill.Id, // ReSharper disable once PossibleInvalidOperationException // Should be set since it's required in the model DrinkId = (uint)item.DrinkId, Quantity = item.Quantity }; dbcontext.RefillContainment.Add(refillContainment); // Update drink states var drink = dbcontext.Drink.FirstOrDefault(d => d.Id == item.DrinkId); if (drink == null) { throw new Exception($"Drink for id {item.DrinkId} went missing"); } // ReSharper disable once PossibleInvalidOperationException // Should be set since it's required in the model drink.Quantity += (int)item.Quantity; dbcontext.Update(drink); } dbcontext.SaveChanges(); return(Ok()); }