public void DeleteService()
        {
            var serviceTemp = new Service()
            {
                HotelId     = this.hotel.Id,
                Code        = "BXH",
                Description = "Brunch Xaris Hotel"
            };

            serviceTemp = this.serviceController.CreateOrUpdateEntity(serviceTemp);

            var servicePricingListTemp = new PricingList()
            {
                BillableEntityId     = serviceTemp.Id,
                TypeOfBillableEntity = TypeOfBillableEntity.Service,
                ValidFrom            = DateTime.Now,
                ValidTo = Convert.ToDateTime("31/01/2017"),
                Price   = 999,
                VatPrc  = 99
            };

            this.pricingListController.CreateOrUpdateEntity(servicePricingListTemp);

            this.serviceController.DeleteEntity(serviceTemp);

            Assert.IsEmpty(this.serviceController.RefreshEntities().Where(x => x.Code == "BXH"));
            Assert.IsEmpty(this.pricingListController.RefreshEntities().Where(x => x.BillableEntityId == serviceTemp.Id && x.TypeOfBillableEntity == TypeOfBillableEntity.Service));
        }
Beispiel #2
0
 public PriceListWrapper(RequestContext context)
     : base(context, SupportedResourceKinds.priceLists)
 {
     _entity         = new PricingList();
     _transformation = TransformationFactory.GetTransformation
                       <ITransformation <PricingListsDocument, PriceListPayload> >
                           (SupportedResourceKinds.priceLists, context);
 }
        public void DeleteRoomType()
        {
            var roomTypeTemp = new RoomType()
            {
                Code    = "Bungallows",
                View    = View.MountainView,
                BedType = BedType.ModernCot,
                Tv      = true,
                WiFi    = true,
                Sauna   = true
            };

            roomTypeTemp = this.roomTypeController.CreateOrUpdateEntity(roomTypeTemp);

            var roomTemp = new Room()
            {
                HotelId    = this.hotel.Id,
                Code       = "Super Extra Room",
                RoomTypeId = roomTypeTemp.Id
            };

            this.roomController.CreateOrUpdateEntity(roomTemp);

            var roomTypePricingListTemp = new PricingList()
            {
                BillableEntityId     = roomTypeTemp.Id,
                TypeOfBillableEntity = TypeOfBillableEntity.RoomType,
                ValidFrom            = DateTime.Now,
                ValidTo = Convert.ToDateTime("31/01/2017").Date,
                Price   = 100,
                VatPrc  = 13
            };

            this.pricingListController.CreateOrUpdateEntity(roomTypePricingListTemp);

            this.roomTypeController.DeleteEntity(roomTypeTemp);

            Assert.IsEmpty(this.roomTypeController.RefreshEntities().Where(x => x.Code == "Bungallows"));
            Assert.IsEmpty(this.roomController.RefreshEntities().Where(x => x.Code == "Super Extra Room"));
            Assert.IsEmpty(this.pricingListController.RefreshEntities().Where(x => x.BillableEntityId == roomTypeTemp.Id && x.TypeOfBillableEntity == TypeOfBillableEntity.RoomType));
        }
        public void GetService()
        {
            var serviceTemp = new Service()
            {
                HotelId     = this.hotel.Id,
                Code        = "BXH",
                Description = "Brunch Xaris Hotel"
            };

            serviceTemp = this.serviceController.CreateOrUpdateEntity(serviceTemp);

            var servicePricingListTemp = new PricingList()
            {
                BillableEntityId     = serviceTemp.Id,
                TypeOfBillableEntity = TypeOfBillableEntity.Service,
                ValidFrom            = DateTime.Now,
                ValidTo = Convert.ToDateTime("31/01/2017"),
                Price   = 999,
                VatPrc  = 99
            };

            servicePricingListTemp = this.pricingListController.CreateOrUpdateEntity(servicePricingListTemp);

            var serviceTemp2 = this.serviceController.RefreshEntities().SingleOrDefault(x => x.Code == "BXH");

            if (serviceTemp2 != null)
            {
                var serviceForCheck = this.serviceController.GetEntity(serviceTemp2.Id);

                var servicePricingListForCheck = this.pricingListController.GetEntity(servicePricingListTemp.Id);

                Assert.AreEqual(serviceForCheck.Code, "BXH");
                Assert.AreEqual(serviceForCheck.Description, "Brunch Xaris Hotel");
                Assert.AreEqual(serviceForCheck.HotelId, this.hotel.Id);

                Assert.AreEqual(servicePricingListForCheck.BillableEntityId, serviceForCheck.Id);

                this.serviceController.DeleteEntity(serviceForCheck);
            }
        }
        public ActionResult UploadPricingDetails(PricingList pricingList, HttpPostedFileBase FileUpload)
        {
            if (User.Identity.IsAuthenticated)
            {
                if (isAdminUser())
                {
                    StringBuilder ErrorMessages   = new StringBuilder();
                    StringBuilder SuccessMessages = null;
                    if (FileUpload != null)
                    {
                        if (FileUpload.ContentType == "application/vnd.ms-excel" || FileUpload.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                        {
                            string filename   = FileUpload.FileName;
                            string targetpath = Server.MapPath("~/Doc/");
                            FileUpload.SaveAs(targetpath + filename);
                            string pathToExcelFile  = targetpath + filename;
                            var    connectionString = "";
                            if (filename.EndsWith(".xls"))
                            {
                                connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", pathToExcelFile);
                            }
                            else if (filename.EndsWith(".xlsx"))
                            {
                                connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", pathToExcelFile);
                            }

                            var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
                            var ds      = new DataSet();

                            adapter.Fill(ds, "ExcelTable");

                            DataTable dtable = ds.Tables["ExcelTable"];

                            string sheetName = "Sheet1";

                            var           excelFile    = new ExcelQueryFactory(pathToExcelFile);
                            var           pricingLists = from a in excelFile.Worksheet <PricingList>(sheetName) select a;
                            StringBuilder ImportValues = new StringBuilder();

                            foreach (var a in pricingLists)
                            {
                                try
                                {
                                    if (a.ProductId != "")
                                    {
                                        PricingList PL = new PricingList();
                                        PL.ProductId   = a.ProductId;
                                        PL.ProductName = a.ProductName;
                                        PL.BuyPrice    = a.BuyPrice;
                                        PL.SellPrice   = a.SellPrice;
                                        PL.Profit      = a.Profit;
                                        PL.MRP         = a.MRP;
                                        string value = "('" + Guid.NewGuid() + "','" + PL.ProductId + "','" + PL.ProductName + "','" + PL.BuyPrice + "','" + PL.SellPrice + "','" + PL.Profit + "','" + PL.MRP + "',1,getdate(),suser_sname(),null,null),";
                                        ImportValues.Append(value);
                                    }
                                }

                                catch (DbEntityValidationException ex)
                                {
                                    foreach (var entityValidationErrors in ex.EntityValidationErrors)
                                    {
                                        foreach (var validationError in entityValidationErrors.ValidationErrors)
                                        {
                                            ErrorMessages.Append("\nProperty: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                        }
                                    }
                                }
                            }
                            //deleting excel file from folder
                            if ((System.IO.File.Exists(pathToExcelFile)))
                            {
                                System.IO.File.Delete(pathToExcelFile);
                            }
                            string ImportData = ImportValues.ToString();
                            ImportData = ImportData.Substring(0, ImportData.Length - 1);
                            PricingDetailsProxy.InsertBulkPricingDetails(ImportData);
                            SuccessMessages = new StringBuilder();
                            SuccessMessages.Append(UploadConstants.UploadSuccessMessage);
                        }
                        else
                        {
                            ErrorMessages.Append(UploadConstants.InvalidFileFormat);
                        }
                    }
                    else
                    {
                        ErrorMessages.Append(UploadConstants.FileNotFound);
                    }
                    if (!String.IsNullOrEmpty(SuccessMessages.ToString()))
                    {
                        TempData[UploadConstants.UploadSuccess] = SuccessMessages.ToString();
                    }
                    if (!String.IsNullOrEmpty(ErrorMessages.ToString()))
                    {
                        TempData[UploadConstants.UploadError] = ErrorMessages.ToString();
                    }
                    return(RedirectToAction("Index", "ManagePricing"));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public JsonResult UploadPricing(PricingList pricingList, HttpPostedFileBase FileUpload)
        {
            List <string> data = new List <string>();

            if (FileUpload != null)
            {
                if (FileUpload.ContentType == "application/vnd.ms-excel" || FileUpload.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                {
                    string filename   = FileUpload.FileName;
                    string targetpath = Server.MapPath("~/Doc/");
                    FileUpload.SaveAs(targetpath + filename);
                    string pathToExcelFile  = targetpath + filename;
                    var    connectionString = "";
                    if (filename.EndsWith(".xls"))
                    {
                        connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", pathToExcelFile);
                    }
                    else if (filename.EndsWith(".xlsx"))
                    {
                        connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", pathToExcelFile);
                    }

                    var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
                    var ds      = new DataSet();

                    adapter.Fill(ds, "ExcelTable");

                    DataTable dtable = ds.Tables["ExcelTable"];

                    string sheetName = "Sheet1";

                    var           excelFile    = new ExcelQueryFactory(pathToExcelFile);
                    var           pricingLists = from a in excelFile.Worksheet <PricingList>(sheetName) select a;
                    StringBuilder ImportValues = new StringBuilder();

                    foreach (var a in pricingLists)
                    {
                        try
                        {
                            if (a.ProductId != "")
                            {
                                PricingList PL = new PricingList();
                                PL.ProductId   = a.ProductId;
                                PL.ProductName = a.ProductName;
                                PL.BuyPrice    = a.BuyPrice;
                                PL.SellPrice   = a.SellPrice;
                                PL.Profit      = a.Profit;
                                PL.MRP         = a.MRP;
                                string value = "('" + Guid.NewGuid() + "','" + PL.ProductId + "','" + PL.ProductName + "','" + PL.BuyPrice + "','" + PL.SellPrice + "','" + PL.Profit + "','" + PL.MRP + "',1,getdate(),suser_sname(),null,null),";
                                ImportValues.Append(value);
                            }
                        }

                        catch (DbEntityValidationException ex)
                        {
                            foreach (var entityValidationErrors in ex.EntityValidationErrors)
                            {
                                foreach (var validationError in entityValidationErrors.ValidationErrors)
                                {
                                    Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                }
                            }
                        }
                    }
                    //deleting excel file from folder
                    if ((System.IO.File.Exists(pathToExcelFile)))
                    {
                        System.IO.File.Delete(pathToExcelFile);
                    }
                    string ImportData = ImportValues.ToString();
                    ImportData = ImportData.Substring(0, ImportData.Length - 1);
                    PricingDetailsProxy.InsertBulkPricingDetails(ImportData);
                    return(Json("success", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    //alert message for invalid file format
                    data.Add("<ul>");
                    data.Add("<li>Only Excel file format is allowed</li>");
                    data.Add("</ul>");
                    data.ToArray();
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                data.Add("<ul>");
                if (FileUpload == null)
                {
                    data.Add("<li>Please choose Excel file</li>");
                }
                data.Add("</ul>");
                data.ToArray();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
        }
 public PriceListFeedEntryWrapper(RequestContext context)
     : base(context, Adapter.Common.SupportedResourceKinds.priceLists)
 {
     _entity    = new PricingList();
     _transform = new PriceListTransform(context);
 }
        public void GetRoomType()
        {
            var roomTypeTemp = new RoomType()
            {
                Code    = "Bungallows",
                View    = View.MountainView,
                BedType = BedType.ModernCot,
                Tv      = true,
                WiFi    = true,
                Sauna   = true
            };

            roomTypeTemp = this.roomTypeController.CreateOrUpdateEntity(roomTypeTemp);

            var roomTemp = new Room()
            {
                HotelId    = this.hotel.Id,
                Code       = "Super Extra Room",
                RoomTypeId = roomTypeTemp.Id
            };

            roomTemp = this.roomController.CreateOrUpdateEntity(roomTemp);

            var roomTypePricingListTemp = new PricingList()
            {
                BillableEntityId     = roomTypeTemp.Id,
                TypeOfBillableEntity = TypeOfBillableEntity.RoomType,
                ValidFrom            = DateTime.Now,
                ValidTo = Convert.ToDateTime("31/01/2017").Date,
                Price   = 100,
                VatPrc  = 13
            };

            roomTypePricingListTemp = this.pricingListController.CreateOrUpdateEntity(roomTypePricingListTemp);

            var roomTypeTemp2 = this.roomTypeController.RefreshEntities().SingleOrDefault(x => x.Code == "Bungallows");

            if (roomTypeTemp2 != null)
            {
                var roomTypeForCheck = this.roomTypeController.GetEntity(roomTypeTemp2.Id);

                var roomForCheck = this.roomController.GetEntity(roomTemp.Id);
                var roomTypePricingListForCheck = this.pricingListController.GetEntity(roomTypePricingListTemp.Id);

                Assert.AreEqual(roomTypeForCheck.Code, "Bungallows");
                Assert.AreEqual(roomTypeForCheck.View, View.MountainView);
                Assert.AreEqual(roomTypeForCheck.BedType, BedType.ModernCot);
                Assert.AreEqual(roomTypeForCheck.Tv, true);
                Assert.AreEqual(roomTypeForCheck.WiFi, true);
                Assert.AreEqual(roomTypeForCheck.Sauna, true);

                Assert.AreEqual(roomForCheck.RoomType.Code, "Bungallows");
                Assert.AreEqual(roomForCheck.RoomType.View, View.MountainView);
                Assert.AreEqual(roomForCheck.RoomType.BedType, BedType.ModernCot);
                Assert.AreEqual(roomForCheck.RoomType.Tv, true);
                Assert.AreEqual(roomForCheck.RoomType.WiFi, true);
                Assert.AreEqual(roomForCheck.RoomType.Sauna, true);

                Assert.AreEqual(roomTypePricingListForCheck.BillableEntityId, roomTypeForCheck.Id);

                this.pricingListController.DeleteEntity(roomTypePricingListForCheck);
                this.roomController.DeleteEntity(roomForCheck);
                this.roomTypeController.DeleteEntity(roomTypeForCheck);
            }
        }
        public void Setup()
        {
            this.hotelController       = new HotelController();
            this.bookingController     = new BookingController();
            this.customerController    = new CustomerController();
            this.serviceController     = new ServiceController();
            this.roomTypeController    = new RoomTypeController();
            this.roomController        = new RoomController();
            this.billingController     = new BillingEntityController();
            this.pricingListController = new PricingListController();

            this.hotel = new Hotel()
            {
                Name    = "Alex Hotel",
                Address = "Syntagma",
                TaxId   = "AH123456",
                Manager = "Alex",
                Phone   = "2101234567",
                Email   = "*****@*****.**"
            };
            this.hotel = this.hotelController.CreateOrUpdateEntity(this.hotel);

            this.roomType = new RoomType()
            {
                Code    = "TreeBed",
                View    = View.MountainView,
                BedType = BedType.ModernCot,
                Tv      = true,
                WiFi    = true,
                Sauna   = true
            };
            this.roomType = this.roomTypeController.CreateOrUpdateEntity(this.roomType);

            this.room = new Room()
            {
                HotelId    = this.hotel.Id,
                Code       = "Alex Hotel 123",
                RoomTypeId = this.roomType.Id
            };
            this.room = this.roomController.CreateOrUpdateEntity(this.room);

            this.service = new Service()
            {
                HotelId     = this.hotel.Id,
                Code        = "AHBF",
                Description = "Breakfast Alex Hotel"
            };
            this.service = this.serviceController.CreateOrUpdateEntity(this.service);

            this.servicePricingList = new PricingList()
            {
                BillableEntityId     = this.service.Id,
                TypeOfBillableEntity = TypeOfBillableEntity.Service,
                ValidFrom            = DateTime.Now,
                ValidTo = Convert.ToDateTime("31/01/2017"),
                VatPrc  = 13
            };
            this.servicePricingList = this.pricingListController.CreateOrUpdateEntity(this.servicePricingList);

            this.roomTypePricingList = new PricingList()
            {
                BillableEntityId     = this.roomType.Id,
                TypeOfBillableEntity = TypeOfBillableEntity.RoomType,
                ValidFrom            = DateTime.Now,
                ValidTo = Convert.ToDateTime("31/01/2017").Date,
                VatPrc  = 13
            };
            this.roomTypePricingList = this.pricingListController.CreateOrUpdateEntity(this.roomTypePricingList);

            this.customer = new Customer()
            {
                Name     = "Thodoris",
                Surname  = "Kapiris",
                TaxId    = "TK1234567",
                IdNumber = "AB1234567",
                Address  = "Monasthraki",
                Email    = "*****@*****.**",
                Phone    = "2107654321"
            };
            this.customer = this.customerController.CreateOrUpdateEntity(this.customer);

            this.booking = new Booking()
            {
                CustomerId  = this.customer.Id,
                RoomId      = this.room.Id,
                From        = DateTime.Now,
                To          = Convert.ToDateTime("31/01/2017"),
                SystemPrice = 12,
                AgreedPrice = 12,
                Status      = Status.New,
                Comments    = "Very good!!"
            };
            this.booking = this.bookingController.CreateOrUpdateEntity(this.booking);

            this.billing = new Billing()
            {
                BookingId        = this.booking.Id,
                PriceForRoom     = this.booking.AgreedPrice,
                PriceForServices = 150,
                TotalPrice       = 12150,
                Paid             = true
            };
            this.billing = this.billingController.CreateOrUpdateEntity(this.billing);
        }
        /// <summary>
        /// The delete pricing list button_ on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void DeletePricingListButton_OnClick(object sender, EventArgs e)
        {
            this.pricingListController = new PricingListController();
            this.roomTypeController    = new RoomTypeController();
            this.serviceController     = new ServiceController();

            var errorlabel = this.Master?.FindControl("form1").FindControl("divErrorMessage") as Label;

            if (errorlabel != null)
            {
                errorlabel.Text = string.Empty;
                if (this.PricingListGridView.VisibleRowCount == 0)
                {
                    errorlabel.Text = $"There are no Pricing Lists to delete";
                }

                var firstRun = true;
                this.Session["errorMessage"] = string.Empty;

                var selectedRowKeys =
                    this.PricingListGridView.GetSelectedFieldValues(this.PricingListGridView.KeyFieldName, "Id");
                if ((selectedRowKeys == null) || (selectedRowKeys.Count == 0))
                {
                    errorlabel.Text = @"Please select a Pricing List first to delete";
                    return;
                }

                foreach (object[] row in selectedRowKeys)
                {
                    var id = Convert.ToInt32(row[0]);
                    var pricingListTemp = new PricingList()
                    {
                        Id = id
                    };
                    try
                    {
                        this.pricingListController.DeleteEntity(pricingListTemp);
                    }
                    catch (ArgumentNullException)
                    {
                        if (firstRun)
                        {
                            errorlabel.Text = $"You can't delete ";
                            firstRun        = false;
                        }

                        errorlabel.Text += $"'{pricingListTemp.Id}',";
                        this.PricingListGridView.Selection.UnselectRowByKey(id);
                    }
                    catch (SqlException exp)
                    {
                        errorlabel.Text = $"Sql error: " + exp.Message;
                    }

                    errorlabel.Text = errorlabel.Text.TrimEnd(' ', ',');
                    this.Session["errorMessage"] = errorlabel.Text;

                    this.RefreshPricingListEntityWithCodeInside();
                }
            }
        }
        /// <summary>
        /// The save button_ on click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void SaveButton_OnClick(object sender, EventArgs e)
        {
            this.pricingList           = new PricingList();
            this.pricingListController = new PricingListController();

            var errorlabel = this.Master?.FindControl("form1").FindControl("divErrorMessage") as Label;

            if (errorlabel != null)
            {
                this.pricingList.Id = Convert.ToInt32(this.idTextBox.Text);

                if (this.pricingList.Id == 0)
                {
                    this.pricingList.TypeOfBillableEntity =
                        (TypeOfBillableEntity)
                        Enum.Parse(typeof(TypeOfBillableEntity), this.typeOFRadioButtonList.SelectedItem.Text);
                    if (this.typeOFRadioButtonList.SelectedItem.Value.ToString() == "RoomType")
                    {
                        var roomTypeList = this.roomTypeComboBox.DataSource as List <RoomType>;
                        if (roomTypeList != null)
                        {
                            var roomTypeTemp =
                                roomTypeList.SingleOrDefault(
                                    x => x.Id == Convert.ToInt32(this.roomTypeComboBox.SelectedItem.Value));
                            this.pricingList.BillableEntityId = roomTypeTemp.Id;
                        }
                    }
                    else if (this.typeOFRadioButtonList.SelectedItem.Value.ToString() == "Service")
                    {
                        var serviceList = this.serviceComboBox.DataSource as List <Service>;
                        if (serviceList != null)
                        {
                            var serviceTemp =
                                serviceList.SingleOrDefault(
                                    x => x.Id == Convert.ToInt32(this.serviceComboBox.SelectedItem.Value));
                            this.pricingList.BillableEntityId = serviceTemp.Id;
                        }
                    }
                }



                this.pricingList.Price     = Convert.ToDouble(this.priceSpinEdit.Number);
                this.pricingList.VatPrc    = Convert.ToDouble(this.VatPrcSpinEdit.Number);
                this.pricingList.ValidFrom = this.validFromDateEdit.Date;
                this.pricingList.ValidTo   = this.validToDateEdit.Date;
                if (this.pricingListController.ValidationDateForPricingList(
                        this.pricingList.ValidFrom,
                        this.pricingList.ValidTo,
                        this.pricingList.TypeOfBillableEntity,
                        this.pricingList.BillableEntityId))
                {
                    this.pricingListController.CreateOrUpdateEntity(this.pricingList);
                    this.Page.Response.Redirect(this.Page.Request.Url.ToString(), true);
                }
                else
                {
                    this.validFromDateEdit.IsValid   = false;
                    this.validToDateEdit.IsValid     = false;
                    this.validFromDateEdit.ErrorText = "There is allready Pricing List for the period you declared!";
                    this.validToDateEdit.ErrorText   = "There is allready Pricing List for the period you declared!";
                }
            }
        }
Beispiel #12
0
        private void ValidatePricings(PricingList pricings)
        {
            Assert.NotEmpty(pricings.Value);

            pricings.Value.ForEach(ValidatePricing);
        }
 public static List <PSSecurityPricing> ConvertToPSType(this PricingList value)
 {
     return(value.Value.Select(pricing => pricing.ConvertToPSType()).ToList());
 }