public List <Category> GetCategories() { using (var context = new MCContext()) { return(context.Categories.ToList()); } }
public Category GetCategory(int ID) { using (var context = new MCContext()) { return(context.Categories.Find(ID)); } }
public ActionResult RetrieveUserReferences() { try { using (MCContext ctx = new MCContext()) { var userReferences = ctx.userReferences .OrderByDescending(x => x.referenceUserId) .ThenByDescending(x => x.id) .Select(x => new { x.totalDiscount, x.status, x.createdDate, x.userInvitation.referenceUserName, x.userInvitation.mailAddress }) .ToList(); return(Json(userReferences, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityService.LogException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "İşlem sırasında bir hata oluştu.")); } }
public ActionResult RetrieveUserInvitations() { try { var userId = Convert.ToInt32(Session["CurrentUserId"]); using (MCContext ctx = new MCContext()) { var invitations = ctx.userInvitations .Where(x => x.referenceUserId == userId) .OrderByDescending(x => x.id) .Select(x => new { x.mailAddress, x.invitationStatus, x.createdDate }) .ToList(); return(Json(invitations, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityService.LogException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "İşlem sırasında bir hata oluştu.")); } }
public List <Category> GetFeaturedCategories() { using (var context = new MCContext()) { return(context.Categories.Where(x => x.isFeatured && x.ImageURL != null).ToList()); } }
public ValidationContext() { _errors = new List <ValidationErrorInfo>(); McContext = new MCContext(false); FileFormat = FileFormatVersions.Office2007; }
public ActionResult RetrieveCampaignRules(int campaignId) { try { using (MCContext ctx = new MCContext()) { var campaignRules = ctx.campaignRules .Where(x => x.campaignId == campaignId) .Select(x => new { x.id, x.activationDay, atLeastPrice = x.atLeastPrice + " TL", x.count, x.description, x.index, x.name, ruleType = x.ruleType == Enums.RuleTypes.percentage ? "%" : "TL" }) .OrderBy(x => x.index) .ToList(); if (campaignRules.Any()) { return(Json(campaignRules, JsonRequestBehavior.AllowGet)); } return(Json(null, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityService.LogException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "İşlem sırasında bir hata oluştu.")); } }
public ActionResult RetrieveUserReferences() { try { var userId = Convert.ToInt32(Session["CurrentUserId"]); using (MCContext ctx = new MCContext()) { var userReferences = ctx.userReferences .Where(x => x.referenceUserId == userId) .OrderByDescending(x => x.id) .Select(x => new { x.userInvitation.mailAddress, x.totalDiscount, x.status, x.createdDate, orders = x.orders.Where(a => a.orderState == Enums.OrderState.paid).Select(y => new { y.activationDate, y.deservedDiscount }) }).ToList(); return(Json(userReferences, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityService.LogException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "İşlem sırasında bir hata oluştu.")); } }
public List <Product> GetProducts(List <int> IDs) { using (var context = new MCContext()) { return(context.Products.Where(product => IDs.Contains(product.ID)).ToList()); } }
public ActionResult DeleteCampaignRule(int campaignRuleId) { try { using (MCContext ctx = new MCContext()) { var rule = ctx.campaignRules.FirstOrDefault(x => x.id == campaignRuleId); if (rule == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Böyle bir veri mevcut değildir.")); } var enableToDelete = ctx.userReferenceOrders.FirstOrDefault(x => x.campaignRuleId == campaignRuleId && x.userReference.campaign.isActive && x.userReference.status != Enums.ReferenceStatus.passive) == null; if (!enableToDelete) { return(new HttpStatusCodeResult(HttpStatusCode.Conflict, "Silmek istediğiniz kural aktif bir siparişe atandığı için silemezsiniz.")); } ctx.campaignRules.Remove(rule); ctx.SaveChanges(); return(Json(new { responseText = "Kural başarıyla silindi." }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityService.LogException(ex); return(Json(new { message = "İşlem sırasında bir hata oluştu.", state = "error" }, JsonRequestBehavior.AllowGet)); } }
public async void GetTest() { var options = new DbContextOptionsBuilder <MCContext>() .UseInMemoryDatabase("MC") .Options; // Insert seed data into the database using one instance of the context await using (var context = new MCContext(options)) { await context.Person.AddRangeAsync(new List <Person> { new Person { Id = 1, FirstName = "Unit Test 1" }, new Person { Id = 2, FirstName = "Unit Test 2" }, new Person { Id = 3, FirstName = "Unit Test 3" } }).ConfigureAwait(false); _ = await context.SaveChangesAsync().ConfigureAwait(false); } // Use a clean instance of the context to run the test await using (var context = new MCContext(options)) { var sut = new PersonRepository(context); var result = await sut.GetPersons("", "ID", true).ConfigureAwait(false); Assert.Equal(3, result.Count); } }
public ActionResult CancelUserReferenceOrder(CancelOrderViewModel data) { try { using (MCContext ctx = new MCContext()) { var userReference = ctx.userReferences.FirstOrDefault(x => x.userId == data.userId); if (userReference == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Referans bulunmamaktadır.")); } var order = ctx.userReferenceOrders.FirstOrDefault(x => x.orderId == data.orderId); if (order == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Sipariş bulunmamaktadır.")); } if (order.activationDate < DateTime.Now) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Sipariş iptal edilemez.")); } order.orderState = Enums.OrderState.canceled; ctx.SaveChanges(); return(new HttpStatusCodeResult(HttpStatusCode.OK, "Sipariş iptal edilmiştir.")); } } catch (Exception ex) { ActivityService.LogException(ex); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "İşlem sırasında bir hata oluştu.")); } }
public List <MedicineModel> GetMedicine() { using (var context = new MCContext()) { var data = context.MedicineModels.ToList(); return(data); } }
public void UpdateCategory(Category category) { using (var context = new MCContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public int GetBillId() { using (var context = new MCContext()) { var billId = context.BillModels.Select(c => c.BillId).DefaultIfEmpty(0).Max(); return(billId + 1); } }
public MedicineModel GetMedicine(int id) { using (var context = new MCContext()) { var medicines = context.MedicineModels.Find(id); return(medicines); } }
public void UpdateMedicine(MedicineModel model) { using (var context = new MCContext()) { context.Entry(model).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void ReferPatient(ReceptionModel receptionModels) { using (var context = new MCContext()) { context.ReceptionModels.Add(receptionModels); context.SaveChanges(); }; }
public List <ReceptionModel> GetPatientByName(string name) { using (var context = new MCContext()) { var data = context.ReceptionModels.Where(c => c.PName == name).ToList(); return(data); }; }
public List <ReceptionModel> GetReception() { using (var context = new MCContext()) { var data = context.ReceptionModels.ToList(); return(data); }; }
public void SaveBill(BillModel model) { using (var context = new MCContext()) { context.BillModels.Add(model); context.SaveChanges(); } }
public List <MedicineModel> GetMedicineList() { using (var context = new MCContext()) { var medicines = context.MedicineModels.ToList(); return(medicines); } }
public void SaveCategory(Category category) { using (var context = new MCContext()) { context.Categories.Add(category); context.SaveChanges(); } }
public Product GetProduct(int ID) { using (var context = new MCContext()) { //return context.Products.Find(ID); return(context.Products.Where(x => x.ID == ID).Include(x => x.Category).FirstOrDefault()); } }
public void UpdateProduct(Product product) { using (var context = new MCContext()) { context.Entry(product).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveMedicine(AppointMedicineModel medicine) { using (var context = new MCContext()) { context.AppointMedicineModels.Add(medicine); context.SaveChanges(); } }
public void SaveAppointment(AppointmentModel appointmentModel) { using (var context = new MCContext()) { context.AppointmentModels.Add(appointmentModel); context.SaveChanges(); } }
public void AddMedicine(MedicineModel MedicineModel) { using (var context = new MCContext()) { context.MedicineModels.Add(MedicineModel); context.SaveChanges(); }; }
public bool IsCheckOut(int id) { using (var context = new MCContext()) { var receptionId = context.AppointmentModels .Where(c => c.PatientId == id).Any(); return(receptionId); } }
public int GetPatientId() { using (var context = new MCContext()) { int maxId = context.ReceptionModels.Select(p => p.PatientId).DefaultIfEmpty(0).Max(); return(maxId + 1); } }