コード例 #1
0
 public List <Category> GetCategories()
 {
     using (var context = new MCContext())
     {
         return(context.Categories.ToList());
     }
 }
コード例 #2
0
 public Category GetCategory(int ID)
 {
     using (var context = new MCContext())
     {
         return(context.Categories.Find(ID));
     }
 }
コード例 #3
0
 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."));
     }
 }
コード例 #4
0
 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."));
     }
 }
コード例 #5
0
 public List <Category> GetFeaturedCategories()
 {
     using (var context = new MCContext())
     {
         return(context.Categories.Where(x => x.isFeatured && x.ImageURL != null).ToList());
     }
 }
コード例 #6
0
        public ValidationContext()
        {
            _errors = new List <ValidationErrorInfo>();

            McContext  = new MCContext(false);
            FileFormat = FileFormatVersions.Office2007;
        }
コード例 #7
0
 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."));
     }
 }
コード例 #8
0
 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."));
     }
 }
コード例 #9
0
ファイル: ProductService.cs プロジェクト: Hardeep097/MartCo
 public List <Product> GetProducts(List <int> IDs)
 {
     using (var context = new MCContext())
     {
         return(context.Products.Where(product => IDs.Contains(product.ID)).ToList());
     }
 }
コード例 #10
0
        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));
            }
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        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."));
            }
        }
コード例 #13
0
 public List <MedicineModel> GetMedicine()
 {
     using (var context = new MCContext())
     {
         var data = context.MedicineModels.ToList();
         return(data);
     }
 }
コード例 #14
0
 public void UpdateCategory(Category category)
 {
     using (var context = new MCContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #15
0
 public int GetBillId()
 {
     using (var context = new MCContext())
     {
         var billId = context.BillModels.Select(c => c.BillId).DefaultIfEmpty(0).Max();
         return(billId + 1);
     }
 }
コード例 #16
0
 public MedicineModel GetMedicine(int id)
 {
     using (var context = new MCContext())
     {
         var medicines = context.MedicineModels.Find(id);
         return(medicines);
     }
 }
コード例 #17
0
 public void UpdateMedicine(MedicineModel model)
 {
     using (var context = new MCContext())
     {
         context.Entry(model).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #18
0
 public void ReferPatient(ReceptionModel receptionModels)
 {
     using (var context = new MCContext())
     {
         context.ReceptionModels.Add(receptionModels);
         context.SaveChanges();
     };
 }
コード例 #19
0
 public List <ReceptionModel> GetPatientByName(string name)
 {
     using (var context = new MCContext())
     {
         var data = context.ReceptionModels.Where(c => c.PName == name).ToList();
         return(data);
     };
 }
コード例 #20
0
 public List <ReceptionModel> GetReception()
 {
     using (var context = new MCContext())
     {
         var data = context.ReceptionModels.ToList();
         return(data);
     };
 }
コード例 #21
0
 public void SaveBill(BillModel model)
 {
     using (var context = new MCContext())
     {
         context.BillModels.Add(model);
         context.SaveChanges();
     }
 }
コード例 #22
0
 public List <MedicineModel> GetMedicineList()
 {
     using (var context = new MCContext())
     {
         var medicines = context.MedicineModels.ToList();
         return(medicines);
     }
 }
コード例 #23
0
 public void SaveCategory(Category category)
 {
     using (var context = new MCContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
コード例 #24
0
ファイル: ProductService.cs プロジェクト: Hardeep097/MartCo
 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());
     }
 }
コード例 #25
0
ファイル: ProductService.cs プロジェクト: Hardeep097/MartCo
 public void UpdateProduct(Product product)
 {
     using (var context = new MCContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #26
0
 public void SaveMedicine(AppointMedicineModel medicine)
 {
     using (var context = new MCContext())
     {
         context.AppointMedicineModels.Add(medicine);
         context.SaveChanges();
     }
 }
コード例 #27
0
 public void SaveAppointment(AppointmentModel appointmentModel)
 {
     using (var context = new MCContext())
     {
         context.AppointmentModels.Add(appointmentModel);
         context.SaveChanges();
     }
 }
コード例 #28
0
        public void AddMedicine(MedicineModel MedicineModel)
        {
            using (var context = new MCContext())
            {
                context.MedicineModels.Add(MedicineModel);

                context.SaveChanges();
            };
        }
コード例 #29
0
 public bool IsCheckOut(int id)
 {
     using (var context = new MCContext())
     {
         var receptionId = context.AppointmentModels
                           .Where(c => c.PatientId == id).Any();
         return(receptionId);
     }
 }
コード例 #30
0
        public int GetPatientId()
        {
            using (var context = new MCContext())
            {
                int maxId = context.ReceptionModels.Select(p => p.PatientId).DefaultIfEmpty(0).Max();

                return(maxId + 1);
            }
        }