public ActionResult DeleteMyLease(int id) { var user = Session[CDictionary.welcome] as CMember; if (user == null) { return(RedirectToAction("Login", "Member")); } var memberId = user.fMemberId; Lease l = dbSA.Lease.FirstOrDefault(t => t.ID == id); string roomID = null; if (l != null) { roomID = l.RoomID.ToString(); dbSA.Lease.Remove(l); dbSA.SaveChanges(); //退租成功通知訊息 CInformationFactory x = new CInformationFactory(); x.Add(memberId, 400, id, 40030); var rf = from r in dbSA.RoomFavorite where r.RoomID.ToString() == roomID select r.MemberID; if (rf != null) { foreach (var item in rf) { int reID = item.Value; //通知空房訊息 CInformationFactory y = new CInformationFactory(); y.Add(reID, 400, 0, 40040); } } return(RedirectToAction("SearchPage")); } return(View(l)); }
public ActionResult BookingInfo(CRoomBooking objBookingInfo) { Lease roomBooking = new Lease() { MemberID = objBookingInfo.MemberId, RoomID = objBookingInfo.RoomId, StartDate = objBookingInfo.StartTime, ExpiryDate = objBookingInfo.EndTime, }; dbSA.Lease.Add(roomBooking); dbSA.SaveChanges(); //訂房成功 CInformationFactory x = new CInformationFactory(); x.Add(objBookingInfo.MemberId, 400, objBookingInfo.RoomId, 40020); return(Json(data: new { message = "Booking is successfully", success = true }, behavior: JsonRequestBehavior.AllowGet)); //return Json(new { data = model }); //return Content(model.MemberId.ToString()); }
public ActionResult Create(CActivityNew ac, string subName) { #region 登入者名稱 //TODO CMember member = Session[CDictionary.welcome] as CMember; if (member == null) { return(RedirectToAction("Login", "Member")); } int memberID = member.fMemberId; #endregion subNamebuffer = subName; SingleApartmentEntities entity = new SingleApartmentEntities(); int sub = 0; var subID = from SUBID in entity.ActivitySubCategory where SUBID.ActivitySubCategoryName == subName select SUBID.ActivitySubCategoryID; foreach (var g in subID) { sub = g; } if (subName != null) { ac.SubCategoryDetailID = sub; int index = ac.myImage.FileName.IndexOf("."); string extention = ac.myImage.FileName.Substring(index, ac.myImage.FileName.Length - index); string photoName = Guid.NewGuid().ToString() + extention; ac.ActivityImage = "../Content/" + photoName; ac.myImage.SaveAs(Server.MapPath("../Content/") + photoName); Activity t = new Activity(); t.ActivityID = ac.ActivityID; t.ActivityName = ac.ActivityName; t.StartTime = ac.StartTime; t.EndTime = ac.EndTime; t.MeetingPoint = ac.MeetingPoint; t.PeopleCount = ac.PeopleCount; t.Note = ac.Note; t.Status = ac.Status; t.SubCategoryDetailID = ac.SubCategoryDetailID; t.MemberID = memberID; t.ActivityImage = ac.ActivityImage; entity.Activity.Add(t); } #region 活動建立人加入活動 Participant p = new Participant(); p.ActivityID = ac.ActivityID; p.MemberID = memberID; entity.Participant.Add(p); #endregion entity.SaveChanges(); #region 活動建立完成後發送訊息 bool flag; CInformationFactory infactory = new CInformationFactory(); int p_source_id = ac.ActivityID; //可能是訂單號碼, 房號 .. flag = infactory.Add(memberID, 200, p_source_id, 20010, subNamebuffer); #endregion #region 活動建立後媒合訊息發送 List <int> MemberIDList = new List <int>(); List <string> MemberfActivityMessageList = new List <string>(); tMember tMember = new tMember(); var membermessage = from mbmsg in entity.tMember select new { MbID = mbmsg.fMemberId, MbMessage = mbmsg.fActivityMessage }; foreach (var m in membermessage) { MemberIDList.Add(m.MbID); MemberfActivityMessageList.Add(m.MbMessage); } for (int me = 0; me < MemberIDList.Count; me++) { if (MemberfActivityMessageList[me] == "TRUE") { flag = infactory.Add(MemberIDList[me], 200, p_source_id, 20040, "(" + subNamebuffer + ")"); } } #endregion return(RedirectToAction("List")); }