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

            McContext  = new MCContext(false);
            FileFormat = FileFormatVersions.Office2007;
        }
Ejemplo n.º 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."));
     }
 }
Ejemplo n.º 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."));
     }
 }
Ejemplo n.º 9
0
 public List <Product> GetProducts(List <int> IDs)
 {
     using (var context = new MCContext())
     {
         return(context.Products.Where(product => IDs.Contains(product.ID)).ToList());
     }
 }
Ejemplo n.º 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));
            }
        }
        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);
            }
        }
Ejemplo n.º 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."));
            }
        }
Ejemplo n.º 13
0
 public List <MedicineModel> GetMedicine()
 {
     using (var context = new MCContext())
     {
         var data = context.MedicineModels.ToList();
         return(data);
     }
 }
Ejemplo n.º 14
0
 public void UpdateCategory(Category category)
 {
     using (var context = new MCContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 15
0
 public int GetBillId()
 {
     using (var context = new MCContext())
     {
         var billId = context.BillModels.Select(c => c.BillId).DefaultIfEmpty(0).Max();
         return(billId + 1);
     }
 }
Ejemplo n.º 16
0
 public MedicineModel GetMedicine(int id)
 {
     using (var context = new MCContext())
     {
         var medicines = context.MedicineModels.Find(id);
         return(medicines);
     }
 }
Ejemplo n.º 17
0
 public void UpdateMedicine(MedicineModel model)
 {
     using (var context = new MCContext())
     {
         context.Entry(model).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 18
0
 public void ReferPatient(ReceptionModel receptionModels)
 {
     using (var context = new MCContext())
     {
         context.ReceptionModels.Add(receptionModels);
         context.SaveChanges();
     };
 }
Ejemplo n.º 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);
     };
 }
Ejemplo n.º 20
0
 public List <ReceptionModel> GetReception()
 {
     using (var context = new MCContext())
     {
         var data = context.ReceptionModels.ToList();
         return(data);
     };
 }
Ejemplo n.º 21
0
 public void SaveBill(BillModel model)
 {
     using (var context = new MCContext())
     {
         context.BillModels.Add(model);
         context.SaveChanges();
     }
 }
Ejemplo n.º 22
0
 public List <MedicineModel> GetMedicineList()
 {
     using (var context = new MCContext())
     {
         var medicines = context.MedicineModels.ToList();
         return(medicines);
     }
 }
Ejemplo n.º 23
0
 public void SaveCategory(Category category)
 {
     using (var context = new MCContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Ejemplo n.º 24
0
 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());
     }
 }
Ejemplo n.º 25
0
 public void UpdateProduct(Product product)
 {
     using (var context = new MCContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 26
0
 public void SaveMedicine(AppointMedicineModel medicine)
 {
     using (var context = new MCContext())
     {
         context.AppointMedicineModels.Add(medicine);
         context.SaveChanges();
     }
 }
Ejemplo n.º 27
0
 public void SaveAppointment(AppointmentModel appointmentModel)
 {
     using (var context = new MCContext())
     {
         context.AppointmentModels.Add(appointmentModel);
         context.SaveChanges();
     }
 }
Ejemplo n.º 28
0
        public void AddMedicine(MedicineModel MedicineModel)
        {
            using (var context = new MCContext())
            {
                context.MedicineModels.Add(MedicineModel);

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

                return(maxId + 1);
            }
        }