コード例 #1
0
 public ActionResult CancelReservedRoom(string roomBookingID)
 {
     try
     {
         int         bookingID   = Int32.Parse(roomBookingID);
         RoomBooking roomBooking = db.RoomBookings.Where(x => x.RoomBookingID.Equals(bookingID)).Single();
         if (roomBooking == null)
         {
             return(Json(new { Status = false }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             SendMailService mailService     = new SendMailService();
             HashCodeService hashCodeService = new HashCodeService();
             String          hashCode        = hashCodeService.createRoomBookingCancelCode(bookingID, roomBooking.Email);
             mailService.toAddress = roomBooking.Email;
             //ND mail gui cho khach hang:
             mailService.body = "CANCEL ROOM BOOKING INFORMATION\n" + "CustomerName: " + roomBooking.Name + "\n"
                                + "ID: " + roomBooking.RoomBookingID + "\n" + "CheckInDate: " + roomBooking.CheckinDate + "\n"
                                + "CheckOutDate: " + roomBooking.CheckoutDate + "\n" + "Click here to cancel your booking: "
                                + "http://localhost:8080/RoomBookings/DeleteRoomBooking/?id="
                                + roomBooking.RoomBookingID + "&hash=" + hashCode;
             mailService.subject = "CANCEL ROOM BOOKING INFORMATION";
             mailService.sendMail();
             return(Json(new { Status = true }, JsonRequestBehavior.AllowGet));
         }
     }
     catch
     {
         return(Json(new { Status = false }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #2
0
        public void CanCalculateHashCode()
        {
            TestClass o1 = new TestClass {
                SomeIntProperty         = 1,
                SomeStringProperty      = "Test",
                SomeNotBusinessProperty = 2
            };
            TestClass o2 = new TestClass {
                SomeIntProperty         = 2,
                SomeStringProperty      = "Test",
                SomeNotBusinessProperty = 2
            };
            TestClass o3 = new TestClass {
                SomeIntProperty         = 1,
                SomeStringProperty      = "Test3",
                SomeNotBusinessProperty = 2
            };
            TestClass o4 = new TestClass {
                SomeIntProperty         = 1,
                SomeStringProperty      = "Test",
                SomeNotBusinessProperty = 3
            };

            int hash1 = HashCodeService.CalculateHashCode(o1, o1.SomeIntProperty, o1.SomeStringProperty);
            int hash2 = HashCodeService.CalculateHashCode(o2, o2.SomeIntProperty, o2.SomeStringProperty);
            int hash3 = HashCodeService.CalculateHashCode(o3, o3.SomeIntProperty, o3.SomeStringProperty);
            int hash4 = HashCodeService.CalculateHashCode(o4, o4.SomeIntProperty, o4.SomeStringProperty);

            Assert.AreNotEqual(hash1, hash2);
            Assert.AreNotEqual(hash1, hash3);
            Assert.AreNotEqual(hash2, hash3);
            Assert.AreEqual(hash1, hash4);
            Assert.AreNotEqual(hash2, hash4);
            Assert.AreNotEqual(hash3, hash4);
        }
コード例 #3
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(HashCodeService.CalculateHashCode(
                this,
                HashCodeService.CalculateCollectionHashCode(_errors)
                ));
 }
コード例 #4
0
 public int GetHashCode(ChildVM obj)
 {
     return(HashCodeService.CalculateHashCode(
                obj,
                obj.IntegerProperty,
                obj.StringProperty
                ));
 }
コード例 #5
0
        internal static string Create(string url, string body)
        {
            var hashSource = string.Concat(url, body);
            IHashCodeService hashCodeService = new HashCodeService();
            var hashCode = hashCodeService.GetHashCodeAndConvertToX2(hashSource);

            return(hashCode.Substring(0, 8));
        }
コード例 #6
0
 public int GetHashCode(ValidationError obj)
 {
     return(HashCodeService.CalculateHashCode(
                obj,
                obj.Details,
                obj.Message,
                obj.Target
                ));
 }
コード例 #7
0
 public override int GetHashCode()
 {
     return(HashCodeService.CalculateHashCode(
                this,
                ChangeType,
                ChangedVM,
                ChangedProperty
                ));
 }
コード例 #8
0
 public override int GetHashCode()
 {
     return(HashCodeService.CalculateHashCode(
                this,
                _validator,
                Target,
                Message,
                Details
                ));
 }
コード例 #9
0
 public override int GetHashCode()
 {
     return(HashCodeService.CalculateHashCode(
                this,
                Step,
                VM,
                Collection,
                Property
                ));
 }
コード例 #10
0
 public override int GetHashCode()
 {
     return(HashCodeService.CalculateHashCode(
                this,
                Type,
                Owner,
                TargetVM,
                TargetCollection,
                TargetProperty,
                ValidatorKey
                ));
 }
コード例 #11
0
        //GET: RoomBookings/DeleteRoomBooking
        public ActionResult DeleteRoomBooking(int id, string hash)
        {
            RoomBooking roomBooking = db.RoomBookings.Where(x => x.RoomBookingID == id).SingleOrDefault();

            if (roomBooking != null)
            {
                HashCodeService hashCodeService = new HashCodeService();
                hash = hash.Replace(' ', '+');
                String hashCode = hashCodeService.createRoomBookingCancelCode(id, roomBooking.Email);

                if (hash.Equals(hashCode))
                {
                    roomBooking.Status          = "Canceled";
                    db.Entry(roomBooking).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Search", "Home"));
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #12
0
 public override int GetHashCode()
 {
     return(HashCodeService.CalculateHashCode(this, VM, Property));
 }