Beispiel #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (Reference != null)
         {
             hashCode = hashCode * 59 + Reference.GetHashCode();
         }
         if (Store != null)
         {
             hashCode = hashCode * 59 + Store.GetHashCode();
         }
         if (OpenHours != null)
         {
             hashCode = hashCode * 59 + OpenHours.GetHashCode();
         }
         if (SpecialHours != null)
         {
             hashCode = hashCode * 59 + SpecialHours.GetHashCode();
         }
         if (Menu != null)
         {
             hashCode = hashCode * 59 + Menu.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #2
0
        public IActionResult AddBankHoliday(OpenHoursViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // Possible exception. The date selected by the client may not correctly represent calender date. Eg. 31st February.
                    DateTime date = new DateTime(model.Year, model.Month, model.Day);

                    OpenHours openHours = new OpenHours
                    {
                        Date      = date,
                        DayName   = date.DayOfWeek,
                        OpenTime  = model.OpenTime,
                        CloseTime = model.CloseTime,
                        Note      = model.Note
                    };

                    openHoursRepository.Add(openHours);

                    return(RedirectToAction("OpenHours", "Home"));
                }
                catch (ArgumentOutOfRangeException)
                {
                    // If the user selects an invalid date such as 31st February, the user is given an error message.
                    ModelState.AddModelError("Date", "The date you selected is invalid");
                    return(View(model));
                }
            }

            return(View(model));
        }
Beispiel #3
0
        /// <summary>
        /// Returns true if StoreMenu instances are equal
        /// </summary>
        /// <param name="input">Instance of StoreMenu to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(StoreMenu input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Reference == input.Reference ||
                     Reference != null &&
                     Reference.Equals(input.Reference)
                     ) &&
                 (
                     Store == input.Store ||
                     Store != null &&
                     Store.Equals(input.Store)
                 ) &&
                 (
                     OpenHours == input.OpenHours ||
                     OpenHours != null &&
                     OpenHours.SequenceEqual(input.OpenHours)
                 ) &&
                 (
                     SpecialHours == input.SpecialHours ||
                     SpecialHours != null &&
                     SpecialHours.SequenceEqual(input.SpecialHours)
                 ) &&
                 (
                     Menu == input.Menu ||
                     Menu != null &&
                     Menu.Equals(input.Menu)
                 ));
        }
Beispiel #4
0
        /// <summary>
        /// Returns true if MenuDetails instances are equal
        /// </summary>
        /// <param name="input">Instance of MenuDetails to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(MenuDetails input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     MenuId == input.MenuId ||
                     MenuId != null &&
                     MenuId.Equals(input.MenuId)
                     ) &&
                 (
                     Name == input.Name ||
                     Name != null &&
                     Name.Equals(input.Name)
                 ) &&
                 (
                     Subtitle == input.Subtitle ||
                     Subtitle != null &&
                     Subtitle.Equals(input.Subtitle)
                 ) &&
                 (
                     IsActive == input.IsActive ||
                     IsActive != null &&
                     IsActive.Equals(input.IsActive)
                 ) &&
                 (
                     IsPosMenu == input.IsPosMenu ||
                     IsPosMenu != null &&
                     IsPosMenu.Equals(input.IsPosMenu)
                 ) &&
                 (
                     LatestMenuUpdate == input.LatestMenuUpdate ||
                     LatestMenuUpdate != null &&
                     LatestMenuUpdate.Equals(input.LatestMenuUpdate)
                 ) &&
                 (
                     LastSuccessfulMenuUpdateAt == input.LastSuccessfulMenuUpdateAt ||
                     LastSuccessfulMenuUpdateAt != null &&
                     LastSuccessfulMenuUpdateAt.Equals(input.LastSuccessfulMenuUpdateAt)
                 ) &&
                 (
                     Url == input.Url ||
                     Url != null &&
                     Url.Equals(input.Url)
                 ) &&
                 (
                     OpenHours == input.OpenHours ||
                     OpenHours != null &&
                     OpenHours.SequenceEqual(input.OpenHours)
                 ) &&
                 (
                     SpecialHours == input.SpecialHours ||
                     SpecialHours != null &&
                     SpecialHours.SequenceEqual(input.SpecialHours)
                 ));
        }
        public void GivenSpecificBusinessHoursInConfiguration_WhenAskingIsOpenAtBottomEdgeOnSaturday_ThenItShouldReturnTrue()
        {
            // arrange
            IOpenHours openHours = new OpenHours(new CallCenterHoursKey());
            DateTime   saturday  = new DateTime(2018, 1, 6, 08, 00, 00);

            // act
            bool actual = openHours.IsOpen(saturday);

            // assert
            actual.Should().BeTrue();
        }
        public void GivenSpecificBusinessHoursInConfiguration_WhenAskingIsOpenAfterTopEdgeOnSunday_ThenItShouldReturnTrue()
        {
            // arrange
            IOpenHours openHours = new OpenHours(new CallCenterHoursKey());
            DateTime   sunday    = new DateTime(2018, 1, 7, 16, 00, 01);

            // act
            bool actual = openHours.IsOpen(sunday);

            // assert
            actual.Should().BeFalse();
        }
Beispiel #7
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (MenuId != null)
         {
             hashCode = hashCode * 59 + MenuId.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Subtitle != null)
         {
             hashCode = hashCode * 59 + Subtitle.GetHashCode();
         }
         if (IsActive != null)
         {
             hashCode = hashCode * 59 + IsActive.GetHashCode();
         }
         if (IsPosMenu != null)
         {
             hashCode = hashCode * 59 + IsPosMenu.GetHashCode();
         }
         if (LatestMenuUpdate != null)
         {
             hashCode = hashCode * 59 + LatestMenuUpdate.GetHashCode();
         }
         if (LastSuccessfulMenuUpdateAt != null)
         {
             hashCode = hashCode * 59 + LastSuccessfulMenuUpdateAt.GetHashCode();
         }
         if (Url != null)
         {
             hashCode = hashCode * 59 + Url.GetHashCode();
         }
         if (OpenHours != null)
         {
             hashCode = hashCode * 59 + OpenHours.GetHashCode();
         }
         if (SpecialHours != null)
         {
             hashCode = hashCode * 59 + SpecialHours.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #8
0
        public IActionResult EditOpenHours(List <OpenHoursViewModel> models)
        {
            if (ModelState.IsValid)
            {
                foreach (var day in models)
                {
                    OpenHours openHours = openHoursRepository.GetOpenHours(day.Id);

                    try
                    {
                        // Days beyond the 7 days are holidays, hence, they includes fields for date and day name.
                        if (day.Id > 7)
                        {
                            // Possible exception. The date selected by the client may not correctly represent calender date. Eg. 31st February.
                            DateTime date = new DateTime(day.Year, day.Month, day.Day);
                            openHours.Date    = date;
                            openHours.DayName = date.DayOfWeek;
                        }
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        // If the user selects an invalid date such as 31st February, the user is given an error message.
                        ModelState.AddModelError("Date", "You have selected an invalid date.");
                        return(View(models));
                    }

                    // Copy the form data to the object to be stored in the database.
                    openHours.OpenTime  = day.OpenTime;
                    openHours.CloseTime = day.CloseTime;
                    openHours.Note      = day.Note;

                    openHoursRepository.Update(openHours);
                }
                return(RedirectToAction("OpenHours", "Home"));
            }

            return(View(models));
        }
Beispiel #9
0
 public BDatetime(IEnumerable <DateTime> holidays, OpenHours openHours)
 {
     _holidays  = dateListToStringList(holidays);
     _openHours = openHours;
 }
        /// <summary>
        /// Response for Pharmacy Details
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pharmacydetailswebservicecall_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
        {
            GetPharmacyInformationResponse objPhDetResponse = null;

            try
            {
                if (e.Result != null)
                {
                    var response = e.Result.ToString();
                    objPhDetResponse = Utils.JsonHelper.Deserialize <GetPharmacyInformationResponse>(response);
                    if ((objPhDetResponse.payload != null) && (objPhDetResponse.status == 0))
                    {
                        App.ObjBrandingResponse = objPhDetResponse;


                        objHomePanoramaVM.AppBarPrimaryColour = App.ObjBrandingResponse.payload.branding_data.appearance.primary_colour;
                        objHomePanoramaVM.PrimaryColour       = Utilities.GetColorFromHexa(App.ObjBrandingResponse.payload.branding_data.appearance.primary_colour);
                        objHomePanoramaVM.SecondaryColour     = Utilities.GetColorFromHexa(App.ObjBrandingResponse.payload.branding_data.appearance.secondary_colour);
                        objHomePanoramaVM.FontColor           = Utilities.GetColorFromHexa(App.ObjBrandingResponse.payload.branding_data.appearance.font_colour);


                        objHomePanoramaVM.PharmacyName       = objPhDetResponse.payload.branding_data.pharmacy_name;
                        objHomePanoramaVM.PharmacyBranchName = objPhDetResponse.payload.branding_data.branch_name + @"               ";
                        App.PharmacyBranchName         = objHomePanoramaVM.PharmacyBranchName;
                        objHomePanoramaVM.AddressLine1 = objPhDetResponse.payload.branding_data.address1;
                        App.LoginPharmacyAddress1      = objPhDetResponse.payload.branding_data.address1;
                        objHomePanoramaVM.AddressLine2 = objPhDetResponse.payload.branding_data.address2;
                        App.LoginPharmacyAddress2      = objPhDetResponse.payload.branding_data.address2;
                        objHomePanoramaVM.AddressLine3 = objPhDetResponse.payload.branding_data.city;
                        objHomePanoramaVM.PinCode      = objPhDetResponse.payload.branding_data.postcode;
                        App.PostCode = objPhDetResponse.payload.branding_data.postcode;
                        objHomePanoramaVM.PharmacistName1 = objPhDetResponse.payload.branding_data.pharmacist1;
                        objHomePanoramaVM.PharmacistName2 = objPhDetResponse.payload.branding_data.pharmacist2;
                        objHomePanoramaVM.WebsiteLink     = objPhDetResponse.payload.branding_data.website;

                        App.PharmacyPhoneNo = objPhDetResponse.payload.branding_data.phone;
                        App.DrugsData       = objPhDetResponse.payload.drugs_data;
                        if (App.DrugDBHash != objPhDetResponse.payload.drugs_hash)
                        {
                            UpdateDBFile();
                        }

                        if (!string.IsNullOrEmpty(objPhDetResponse.payload.branding_data.twitter_link) && !string.IsNullOrWhiteSpace(objPhDetResponse.payload.branding_data.twitter_link))
                        {
                            objHomePanoramaVM.IsTwitterLinkVisible = Visibility.Visible;
                            objHomePanoramaVM.TwitterLink          = objPhDetResponse.payload.branding_data.twitter_link;
                        }
                        if (!string.IsNullOrEmpty(objPhDetResponse.payload.branding_data.facebook_link) && !string.IsNullOrWhiteSpace(objPhDetResponse.payload.branding_data.facebook_link))
                        {
                            objHomePanoramaVM.IsFacebookLinkVisible = Visibility.Visible;
                            objHomePanoramaVM.FacebookLink          = objPhDetResponse.payload.branding_data.facebook_link;
                        }

                        if (objPhDetResponse.payload.branding_data.opening_hours != null)
                        {
                            bool   isClosedToday = objPhDetResponse.payload.branding_data.opening_hours.SingleOrDefault(s => s.dayname == Convert.ToString(System.DateTime.Today.DayOfWeek)).is_closed;
                            string openingTime   = Convert.ToString(objPhDetResponse.payload.branding_data.opening_hours.SingleOrDefault(s => s.dayname == Convert.ToString(System.DateTime.Today.DayOfWeek)).open);
                            string closingTime   = Convert.ToString(objPhDetResponse.payload.branding_data.opening_hours.SingleOrDefault(s => s.dayname == Convert.ToString(System.DateTime.Today.DayOfWeek)).close);
                            string todayOpenTime = !isClosedToday ? openingTime + "-" + closingTime : "Closed";

                            objHomePanoramaVM.Opentodaytime = todayOpenTime;

                            List <OpenHours> lstOpenHours = new List <OpenHours>();
                            OpenHours        objOpenHours;
                            foreach (var item in objPhDetResponse.payload.branding_data.opening_hours)
                            {
                                objOpenHours = new OpenHours {
                                    DayName = item.dayname, Timings = !item.is_closed ? item.open + "-" + item.close : "Closed"
                                };
                                lstOpenHours.Add(objOpenHours);
                            }
                            objHomePanoramaVM.OpeningHours = lstOpenHours;
                        }

                        if (objPhDetResponse.payload.advert_data != null)
                        {
                            objHomePanoramaVM.AdvertisementData = new ObservableCollection <AdvertData>(objPhDetResponse.payload.advert_data);
                            App.AdImages = null;
                            foreach (var item in objPhDetResponse.payload.advert_data)
                            {
                                if (App.AdImages == null)
                                {
                                    App.AdImages = new List <string>();
                                    App.AdImages.Add(item.image_url.Replace("https", "http"));
                                }
                                else
                                {
                                    App.AdImages.Add(item.image_url.Replace("https", "http"));
                                }
                            }
                        }
                        objHomePanoramaVM.ProgressBarVisibilty = Visibility.Collapsed;
                    }
                }
            }
            catch (Exception)
            {
                objHomePanoramaVM.ProgressBarVisibilty = Visibility.Collapsed;
            }
        }