Exemplo n.º 1
0
        public async Task <InvoiceHeaderSet> CreateInvoiceAndReservation(InvoiceHeaderSet invoiceHeaderSet)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    // check the dubllicate date.
                    var existedItem = context.InvoiceHeaderSet.Include("ReservationSet").Where(u => u.InvoiceHeaderSetId == invoiceHeaderSet.InvoiceHeaderSetId).FirstOrDefault();
                    InvoiceHeaderSet addNewInvoiceHeader = null;
                    if (existedItem != null)
                    {
                        existedItem.ReservationSet.Name = invoiceHeaderSet.ReservationSet.Name;
                        existedItem.ReservationSet.Phone = invoiceHeaderSet.ReservationSet.Phone;
                        existedItem.ReservationSet.Description = invoiceHeaderSet.ReservationSet.Description;
                        existedItem.ReservationSet.Email = invoiceHeaderSet.ReservationSet.Email;
                        existedItem.ReservationSet.Amount = invoiceHeaderSet.ReservationSet.Amount;
                        existedItem.ReservationSet.DateTime = invoiceHeaderSet.ReservationSet.DateTime;
                        existedItem.Number = invoiceHeaderSet.Number;
                        context.SaveChanges();
                        return existedItem;
                    }
                    else
                    {
                        DateTime ResevationSearchDate = invoiceHeaderSet.CreateDate.Value;
                        var result = context.InvoiceHeaderSet.Include("ReservationSet").Where(u => u.Number == invoiceHeaderSet.Number && u.PayDate == null && u.Description == null && ResevationSearchDate.Date.Day == u.CreateDate.Value.Day && ResevationSearchDate.Date.Month == u.CreateDate.Value.Month && ResevationSearchDate.Date.Year == u.CreateDate.Value.Year).ToList() ?? null;
                        if (result.Count >= 1)
                        {
                            foreach (var invoiceHeaders in result)
                            {
                                DateTime reservationDate = invoiceHeaders.CreateDate.Value;

                                int one = reservationDate.TimeOfDay.Hours * 60 + reservationDate.Minute;
                                int two = ResevationSearchDate.TimeOfDay.Hours * 60 + ResevationSearchDate.Minute;

                                int diff = Math.Abs(one - two);

                                if (diff >= 180)
                                {
                                    addNewInvoiceHeader = context.InvoiceHeaderSet.Add(invoiceHeaderSet);
                                    context.SaveChanges();
                                }
                            }
                        }
                        else
                        {
                            addNewInvoiceHeader = context.InvoiceHeaderSet.Add(invoiceHeaderSet);
                            context.SaveChanges();
                        }
                    }
                    return addNewInvoiceHeader;
                }
            }));
        }
Exemplo n.º 2
0
        public async Task <bool> DeleteEmpyItems(InvoiceHeaderSet invoiceHeaderSet)
        {
            await Task.Run(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    if (invoiceHeaderSet != null)
                    {
                        InvoiceHeaderSet CurrentInvoiceHeaderSet = context.InvoiceHeaderSet.Include("InvoiceHeaderDetailsSet.ItemSet").Include("ReservationSet").Where(x => x.InvoiceHeaderSetId == invoiceHeaderSet.InvoiceHeaderSetId).FirstOrDefault() ?? null;
                        if (CurrentInvoiceHeaderSet != null)
                        {
                            if (CurrentInvoiceHeaderSet.InvoiceHeaderDetailsSet.Count != 0)
                            {
                                foreach (var item in CurrentInvoiceHeaderSet.InvoiceHeaderDetailsSet.ToList())
                                {
                                    if (item.Quantity <= 0)
                                    {
                                        CurrentInvoiceHeaderSet.InvoiceHeaderDetailsSet.ToList().ForEach(p => p.InvoiceHeaderSet.InvoiceHeaderDetailsSet.Remove(item));
                                        context.Entry(item).State = EntityState.Deleted;
                                    }
                                }
                            }
                            else if (CurrentInvoiceHeaderSet.InvoiceHeaderDetailsSet.Count == 0 && CurrentInvoiceHeaderSet.ReservationSet == null)
                            {
                                context.InvoiceHeaderSet.Remove(CurrentInvoiceHeaderSet);
                            }
                            context.SaveChanges();
                        }
                    }
                }
            });

            return(true);
        }
Exemplo n.º 3
0
        public async Task <CreatorSet> addCreatorWorkingHours(CreatorSet creatorSet, DateTime workinghoursSet, DateTime addStartWorkingHourSet, DateTime addEndWorkingHourSet)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    //   DateTime saveNow =

                    WorkinghoursSet workingHourset = new WorkinghoursSet();

                    workingHourset.StartHour = new DateTime(workinghoursSet.Year, workinghoursSet.Month, workinghoursSet.Day, addStartWorkingHourSet.Hour, addStartWorkingHourSet.Minute, 0);

                    workingHourset.EndHour = new DateTime(workinghoursSet.Year, workinghoursSet.Month, workinghoursSet.Day, addEndWorkingHourSet.Hour, addEndWorkingHourSet.Minute, 0);;

                    var findCreatorSet = context.CreatorSet.Include("WorkinghoursSet").Where(x => x.CreatorId == creatorSet.CreatorId).FirstOrDefault();

                    foreach (var workinghours in findCreatorSet.WorkinghoursSet.ToList())
                    {
                        if (workinghours.StartHour.Value.Date != workingHourset.StartHour.Value.Date)
                        {
                            findCreatorSet.WorkinghoursSet.Add(workingHourset);
                            context.SaveChanges();
                            break;
                        }
                    }

                    return findCreatorSet;
                    //&& u.WorkinghoursSet.(y => y.StartHour.Value.Date == DateTime.Now.Date)
                }
            }));
        }
Exemplo n.º 4
0
        public JsonResult createReservationSet(ReservationSet reservationSet)
        {
            if (reservationSet != null)
            {
                using (CasierContents dataContext = new CasierContents())
                {
                    var findItem = dataContext.ItemSet.Where(x => x.Name.Equals(reservationSet.Phone)).FirstOrDefault();
                    if (findItem == null)
                    {
                        dataContext.ReservationSet.Add(reservationSet);
                        dataContext.SaveChanges();
                        var results = new { Success = "True", Message = "Succesfull" };
                        return(Json(results, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        var results = new { Success = "False", Message = "Error" };
                        return(Json(results, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            var result = new { Success = "False", Message = "Error" };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
 public async Task <InvoiceHeaderSet> InsertInvoiceDeitails(int invoiceHeader, int quantity, string number)
 {
     return(await Task.Factory.StartNew(() =>
     {
         using (CasierContents context = new CasierContents())
         {
             {
                 InvoiceHeaderSet findInvoiceHeaderSet = context.InvoiceHeaderSet.Include("InvoiceHeaderDetailsSet.ItemSet").Where(x => x.InvoiceHeaderSetId == invoiceHeader).FirstOrDefault() ?? null;
                 {
                     if (findInvoiceHeaderSet.InvoiceHeaderDetailsSet.Count == 0)
                     {
                         InvoiceHeaderDetailsSet CreateNewInvoiceHeaderDetailset = new InvoiceHeaderDetailsSet();
                         CreateNewInvoiceHeaderDetailset.OrderTime = DateTime.Now;
                         ItemSet itemSet = context.ItemSet.Where(x => x.Number == number).FirstOrDefault() ?? null;
                         CreateNewInvoiceHeaderDetailset.ItemSet = itemSet;
                         if (CreateNewInvoiceHeaderDetailset.Quantity == null)
                         {
                             CreateNewInvoiceHeaderDetailset.Quantity = (short)quantity;
                         }
                         findInvoiceHeaderSet.InvoiceHeaderDetailsSet.Add(CreateNewInvoiceHeaderDetailset);
                     }
                     // hvis der er flere items så skal der lægges sammen.
                     else if (findInvoiceHeaderSet.InvoiceHeaderDetailsSet.Count > 0)
                     {
                         var findTheCOrrectOne = findInvoiceHeaderSet.InvoiceHeaderDetailsSet.Where(x => x.ItemSet.Number == number).FirstOrDefault();
                         if (findTheCOrrectOne != null)
                         {
                             if (findTheCOrrectOne.Quantity != null)
                             {
                                 findTheCOrrectOne.Quantity += (short)quantity;
                             }
                             else
                             {
                                 findTheCOrrectOne.Quantity = (short)quantity;
                             }
                             if (findTheCOrrectOne.Quantity <= 0)
                             {
                                 context.InvoiceHeaderDetailsSet.Remove(findTheCOrrectOne);
                             }
                         }
                         else if (findTheCOrrectOne == null && quantity > 0)
                         {
                             InvoiceHeaderDetailsSet CreateNewInvoiceHeaderDetailsets = new InvoiceHeaderDetailsSet();
                             CreateNewInvoiceHeaderDetailsets.OrderTime = DateTime.Now;
                             ItemSet itemSet = context.ItemSet.Where(x => x.Number == number).FirstOrDefault() ?? null;
                             CreateNewInvoiceHeaderDetailsets.ItemSet = itemSet;
                             itemSet.InvoiceHeaderDetailsSet.Add(CreateNewInvoiceHeaderDetailsets);
                             CreateNewInvoiceHeaderDetailsets.Quantity = (short)quantity;
                             findInvoiceHeaderSet.InvoiceHeaderDetailsSet.Add(CreateNewInvoiceHeaderDetailsets);
                         }
                     }
                 }
                 context.SaveChanges();
                 context.InvoiceHeaderSet.Add(findInvoiceHeaderSet);
                 return findInvoiceHeaderSet;
             }
         }
     }));
 }
Exemplo n.º 6
0
        public async Task <InvoiceHeaderSet> splitUpForV(InvoiceHeaderSet invoiceHeaderSet, List <InvoiceHeaderDetailsSet> invoiceDetails, bool takeAway, int total)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    int TakeAwayTotal = 0;
                    InvoiceHeaderSet currentInvoiceHeaderSet = new InvoiceHeaderSet();
                    currentInvoiceHeaderSet.PayDate = DateTime.Now;
                    currentInvoiceHeaderSet.Number = invoiceHeaderSet.Number;
                    //currentInvoiceHeaderSet.InvoiceHeaderDetailsSet = invoiceDetails;
                    foreach (var item in invoiceDetails)
                    {
                        InvoiceHeaderDetailsSet CreateNewInvoiceHeaderDetailsets = new InvoiceHeaderDetailsSet();
                        ItemSet itemSet = context.ItemSet.Where(x => x.Number == item.ItemSet.Number).FirstOrDefault() ?? null;
                        CreateNewInvoiceHeaderDetailsets.ItemSet = itemSet;
                        CreateNewInvoiceHeaderDetailsets.Quantity = item.Quantity;
                        CreateNewInvoiceHeaderDetailsets.OrderTime = DateTime.Now;
                        currentInvoiceHeaderSet.InvoiceHeaderDetailsSet.Add(CreateNewInvoiceHeaderDetailsets);
                        int quantity = (int)item.Quantity;
                        int price = (int)(item.ItemSet.Price);
                        int sum = quantity *price;
                        if (item.ItemSet.Discount != null)
                        {
                            int rabat = (int)item.ItemSet.Price * (int)item.ItemSet.Discount / 100;
                            sum = sum - rabat;
                        }

                        TakeAwayTotal += (int)sum;
                    }

                    if (takeAway)
                    {
                        currentInvoiceHeaderSet.Total = TakeAwayTotal;
                    }
                    else
                    {
                        currentInvoiceHeaderSet.Total = total;
                    }

                    context.InvoiceHeaderSet.Add(currentInvoiceHeaderSet);
                    //  context.SaveChanges();

                    // update newone


                    InvoiceHeaderSet currentInvoiceHeader = context.InvoiceHeaderSet.Include("InvoiceHeaderDetailsSet.ItemSet").Where(x => x.InvoiceHeaderSetId == invoiceHeaderSet.InvoiceHeaderSetId).FirstOrDefault() ?? null;
                    foreach (var item in invoiceHeaderSet.InvoiceHeaderDetailsSet)
                    {
                        context.InvoiceHeaderDetailsSet.AddOrUpdate(item);
                    }


                    context.SaveChanges();
                    return currentInvoiceHeader;
                }
            }));
        }
Exemplo n.º 7
0
        public async Task <WorkinghoursSet> CreatorsCheckIn(CreatorSet creator)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    var findCreator = context.CreatorSet.Where(x => x.CreatorId == creator.CreatorId).FirstOrDefault();

                    var findWorkingHourExist = context.WorkinghoursSet.Where(x => findCreator.CreatorId == x.CreatorSet.CreatorId).ToList();

                    WorkinghoursSet findToworkingHours = null;



                    foreach (var workinghours in findWorkingHourExist)
                    {
                        if (workinghours.StartHour != null)
                        {
                            if (workinghours.StartHour.Value.Date == DateTime.Now.Date)
                            {
                                findToworkingHours = workinghours;
                            }
                        }
                    }

                    //    x.StartHour.Value.Date.Month == DateTime.Now.Date.Month && x.StartHour.Value.Year == DateTime.Now.Date.Year && x.StartHour.Value.Date.Day == DateTime.Now.Date.Day

                    if (findToworkingHours == null)
                    {
                        WorkinghoursSet workingourset = new WorkinghoursSet();
                        workingourset.StartHour = DateTime.Now;
                        findCreator.WorkinghoursSet.Add(workingourset);
                        context.SaveChanges();
                        return workingourset;
                    }
                    else if (findToworkingHours != null)
                    {
                        findToworkingHours.StartHour = DateTime.Now;
                        context.SaveChanges();
                        return findToworkingHours;
                    }
                    return null;
                }
            }));
        }
Exemplo n.º 8
0
        public JsonResult DeleteItem(ItemSet items)
        {
            if (items != null)
            {
                using (CasierContents dataContext = new CasierContents())
                {
                    dataContext.Configuration.ProxyCreationEnabled  = false;
                    dataContext.Configuration.LazyLoadingEnabled    = false;
                    dataContext.Configuration.ValidateOnSaveEnabled = false;

                    //var category = items.CategorySet;
                    //var fintTheCategory = dataContext.CategorySet.Where(x => x.CategoryId == category.CategoryId).FirstOrDefault();

                    //if (fintTheCategory != null)
                    {
                        var findItem = dataContext.ItemSet.Include("InvoiceHeaderDetailsSet").Where(x => x.ItemSetId == items.ItemSetId).FirstOrDefault();



                        dataContext.ItemSet.Attach(findItem);
                        dataContext.Entry(findItem).Collection("InvoiceHeaderDetailsSet").Load();
                        //  findItem.CategorySet.ItemSet.Remove(findItem);
                        findItem.InvoiceHeaderDetailsSet.ToList().ForEach(I => dataContext.InvoiceHeaderDetailsSet.Remove(I));
                        dataContext.ItemSet.Remove(findItem);
                        dataContext.SaveChanges();



                        dataContext.SaveChanges();
                        var results = new { Success = "True", Message = "Succesfull" };
                        return(Json(results, JsonRequestBehavior.AllowGet));
                    }


                    var result = new { Success = "True", Message = "Succesfull" };
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                var result = new { Success = "True", Message = "Error" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 9
0
        public async Task <CreatorSet> GetAndUpdateCreators(CreatorSet creator)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    // check the dubllicate date.
                    var existedItem = context.CreatorSet.Include("WorkinghoursSet").Where(u => u.CPR != null && u.CreatorId == creator.CreatorId).FirstOrDefault();

                    if (existedItem != null)
                    {
                        existedItem.BankInfo = creator.BankInfo;
                        existedItem.CPR = creator.CPR;
                        existedItem.Description = creator.Description;
                        existedItem.Evaluation = creator.Evaluation;
                        existedItem.HourSalary = creator.HourSalary;
                        existedItem.MonthSalary = creator.MonthSalary;
                        existedItem.Name = creator.Name;
                        existedItem.Phone = creator.Phone;
                        existedItem.WorkinghoursSet = creator.WorkinghoursSet;
                        context.SaveChanges();
                        return existedItem;
                    }
                    else
                    {
                        CreatorSet newCreatorSet = new CreatorSet();
                        newCreatorSet.BankInfo = creator.BankInfo;
                        newCreatorSet.CPR = creator.CPR;
                        newCreatorSet.Description = creator.Description;
                        newCreatorSet.Evaluation = creator.Evaluation;
                        newCreatorSet.HourSalary = creator.HourSalary;
                        newCreatorSet.MonthSalary = creator.MonthSalary;
                        newCreatorSet.Name = creator.Name;
                        newCreatorSet.Phone = creator.Phone;
                        newCreatorSet.WorkinghoursSet = creator.WorkinghoursSet;
                        context.CreatorSet.Add(newCreatorSet);
                        context.SaveChanges();
                        return newCreatorSet;
                    }
                }
            }));
        }
Exemplo n.º 10
0
 public async Task <bool> DeleteCreatorSet(CreatorSet creatorSet)
 {
     return(await Task.Factory.StartNew(() =>
     {
         using (CasierContents context = new CasierContents())
         {
             var deleteItemReservationSet = context.CreatorSet.Find(creatorSet.CreatorId);
             deleteItemReservationSet.CPR = null;
             context.SaveChanges();
             return true;
         }
     }));
 }
Exemplo n.º 11
0
 public async Task <WorkinghoursSet> SaveTimeReg(WorkinghoursSet workinghoursSet)
 {
     return(await Task.Factory.StartNew(() =>
     {
         using (CasierContents context = new CasierContents())
         {
             var getItems = context.WorkinghoursSet.Where(x => x.WorkingHoursId == workinghoursSet.WorkingHoursId).FirstOrDefault();
             getItems.StartHour = workinghoursSet.StartHour;
             getItems.EndHour = workinghoursSet.EndHour;
             context.SaveChanges();
             return getItems;
         }
     }));
 }
Exemplo n.º 12
0
        public JsonResult AddItems(ItemSet item)
        {
            if (item != null)
            {
                using (CasierContents dataContext = new CasierContents())
                {
                    var findItem = dataContext.ItemSet.Where(x => x.Number.Equals(item.Number)).FirstOrDefault();
                    if (findItem == null)
                    {
                        var fintTheCategory = dataContext.CategorySet.Where(x => x.Name.Equals(item.CategorySet.Name)).FirstOrDefault();

                        if (fintTheCategory == null)
                        {
                            dataContext.ItemSet.Add(item);
                            fintTheCategory.ItemSet.Add(item);
                            dataContext.SaveChanges();
                            var results = new { Success = "True", Message = "Succesfull" };
                            return(Json(results, JsonRequestBehavior.AllowGet));
                        }
                        else if (fintTheCategory != null)
                        {
                            fintTheCategory.ItemSet.Add(item);
                            item.CategorySet = fintTheCategory;
                            dataContext.ItemSet.Add(item);
                            dataContext.SaveChanges();
                            var results = new { Success = "True", Message = "Succesfull" };
                            return(Json(results, JsonRequestBehavior.AllowGet));
                        }
                    }
                }
            }

            var result = new { Success = "False", Message = "Error" };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 13
0
 public JsonResult DeleteCategory(CategorySet category)
 {
     if (category != null)
     {
         {
             var FindCategory = dataContext.CategorySet.Where(x => x.CategoryId == category.CategoryId).FirstOrDefault();
             dataContext.CategorySet.Remove(FindCategory);
             dataContext.SaveChanges();
             var result = new { Success = "True", Message = "Succesfull" };
             return(Json(result, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         var result = new { Success = "True", Message = "Error" };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 14
0
        public async Task <bool> DeleteCurrentItem(InvoiceHeaderSet invoiceHeaderSet)
        {
            using (CasierContents context = new CasierContents())
            {
                await Task.Run(() =>
                {
                    if (invoiceHeaderSet != null)
                    {
                        var CurrentInvoiceHeaderSet = context.InvoiceHeaderSet.Where(x => x.InvoiceHeaderSetId == invoiceHeaderSet.InvoiceHeaderSetId).FirstOrDefault();
                        //context.InvoiceHeaderSet.Attach(CurrentInvoiceHeaderSet);
                        CurrentInvoiceHeaderSet.Description = "" + DateTime.Now + " blev slettet";
                        context.SaveChanges();
                    }
                });

                return(true);
            }
        }
Exemplo n.º 15
0
        public async Task <CreatorSet> CreatorsCheckOut(CreatorSet creator, WorkinghoursSet workinghoursSet)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    /*  var findTheCurrentworkinghoursSet = context.WorkinghoursSet.Where(x => x.WorkingHoursId == creator.WorkinghoursSet.First()).FirstOrDefault();*/



                    var workinghour = context.WorkinghoursSet.Find(workinghoursSet.WorkingHoursId);
                    if (workinghour.EndHour == null && workinghour.StartHour.Value.Date == DateTime.Now.Date)
                    {
                        workinghour.EndHour = DateTime.Now;
                        context.SaveChanges();
                    }
                    return creator;
                }
            }));
        }
Exemplo n.º 16
0
        public async Task <bool> DeleteReservationSet(InvoiceHeaderSet invoiceHeaderSet)
        {
            return(await Task.Factory.StartNew(() =>
            {
                using (CasierContents context = new CasierContents())
                {
                    var deleteItemReservationSet = context.ReservationSet.Find(invoiceHeaderSet.ReservationSet.ReservationId);
                    context.ReservationSet.Remove(deleteItemReservationSet);


                    var deleteItemInvoiceHeader = context.InvoiceHeaderSet.Find(invoiceHeaderSet.InvoiceHeaderSetId);
                    context.InvoiceHeaderSet.Remove(deleteItemInvoiceHeader);
                    context.SaveChanges();



                    return true;
                }
            }));
        }
Exemplo n.º 17
0
 public JsonResult AddCategory(CategorySet categorySet)
 {
     if (categorySet != null)
     {
         using (CasierContents dataContext = new CasierContents())
         {
             if (!dataContext.CategorySet.Any(o => o.Name == categorySet.Name))
             {
                 dataContext.CategorySet.Add(categorySet);
             }
             dataContext.SaveChanges();
             var result = new { Success = "True", Message = "Succesfull" };
             return(Json(result, JsonRequestBehavior.AllowGet));
         }
     }
     else
     {
         var result = new { Success = "False", Message = "Error" };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 18
0
        public JsonResult UpdateItemSet(string Name, int ItemSetId, string Number, decimal Price, short Discount)
        {
            using (CasierContents dataContext = new CasierContents())
            {
                ItemSet currentItemSet = dataContext.ItemSet.Where(b => b.ItemSetId == ItemSetId).FirstOrDefault();

                // Category category = itemsetId.Category1;
                if (currentItemSet.Number.Equals(Number))
                {
                    currentItemSet.Name     = Name;
                    currentItemSet.Number   = Number;
                    currentItemSet.Price    = Price;
                    currentItemSet.Discount = Discount;
                    dataContext.SaveChanges();
                }
            }

            var result = new { Success = "True", Message = "Succesfull" };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
 public async Task <InvoiceHeaderSet> StartCreateInvoiceOrfindexists(string number, DateTime searchDate)
 {
     return(await Task.Factory.StartNew(() =>
     {
         using (CasierContents context = new CasierContents())
         {
             InvoiceHeaderSet result = context.InvoiceHeaderSet.Include("InvoiceHeaderDetailsSet.ItemSet").Where(u => u.Number.Equals(number) && u.PayDate == null && u.Description == null && u.ReservationSet == null && searchDate.Month.Equals(u.CreateDate.Value.Month) && searchDate.Day.Equals(u.CreateDate.Value.Day) && searchDate.Year.Equals(u.CreateDate.Value.Year)).FirstOrDefault();
             if (result != null)
             {
                 return result;
             }
             else
             {
                 InvoiceHeaderSet newOne = new InvoiceHeaderSet();
                 newOne.CreateDate = DateTime.Now;
                 newOne.Number = number;
                 newOne.Total = 0;
                 context.InvoiceHeaderSet.Add(newOne);
                 context.SaveChanges();
                 return newOne;
             }
         }
     }));
 }