public ActionResult Create(FormCollection collection, Location location, string Upload) { try { ImageController ac = new ImageController(); List <UploadFile> uploadFiles = ac.GenerateAttachFileCollectionID(collection, "Location"); if (Upload != null) { ImageUploadToServer(); if (uploadFiles != null) { ModelStateSetting(uploadFiles, "Location"); } return(View()); } foreach (UploadFile uploadFile in uploadFiles) { LocationUploadFile auf = new LocationUploadFile(); auf.UploadFileID = uploadFile.ID; location.LocationUploadFiles.Add(auf); } _entities.AddToLocations(location); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection, ProductDiscount productDiscount) { try { _entities.AddToProductDiscounts(productDiscount); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void ChangeUploadFileValues() { List <UploadFile> uploadFiles = _entities.UploadFiles.ToList(); foreach (UploadFile up in uploadFiles) { if (up.Name.StartsWith("image") || up.Name.StartsWith("Jewelry")) { up.FilePath = "../../images/SMProducts/"; } } _entities.SaveChanges(); }
//public bool MemberRegister(RegisterModel model, string[] roles) //{ // bool result = false; // if (ModelState.IsValid) // { // if (MembershipService == null) // { // MembershipService = new AccountMembershipService(); // } // // Attempt to register the user // MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email, true); // if (createStatus == MembershipCreateStatus.Success) // { // UpdateMemberInfo(model); // Roles.AddUserToRoles(model.UserName, roles); // result = true; // } // else // { // ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus)); // } // } // return result; //} public void UpdateMemberInfo(RegisterModel register) { MemberInfo memberInfo = new MemberInfo(); memberInfo.InitiateTypeID = register.InitiateTypeID; memberInfo.Name = register.Name; MembershipUser mUser = Membership.GetUser(register.UserName); memberInfo.MemberID = (Guid)(mUser.ProviderUserKey); _entities.AddToMemberInfos(memberInfo); _entities.SaveChanges(); }
public ActionResult Create(int volunteerJobTypeID, FormCollection collection, GMVolunteerJobName gmVolunteerJobName) { try { gmVolunteerJobName.VolunteerJobTypeID = volunteerJobTypeID; _entities.AddToGMVolunteerJobNames(gmVolunteerJobName); _entities.SaveChanges(); return(RedirectToAction("Index", new { volunteerJobTypeID = volunteerJobTypeID })); } catch { return(View()); } }
public ActionResult Create(FormCollection collection, ProductDetail productDetail, int productID) { //Product product = _entities.Products.SingleOrDefault(a => a.ID == productID); try { //product.ProductDetails.Add(productDetail); _entities.AddToProductDetails(productDetail); _entities.SaveChanges(); return(RedirectToAction("Index", "ProductDetail", new { productID = productID })); } catch { return(View()); } }
public ActionResult Create(FormCollection collection, BlackListMember BlackListMember) { try { //BlackListMember.MemberD = Guid.Parse(collection.GetValues("BlackListMember.MemberID")[0]); _entities.AddToBlackListMembers(BlackListMember); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection, InitiateVisitor initiateVisitor) { try { _entities.AddToInitiateVisitors(initiateVisitor); _entities.SaveChanges(); GenerateEmailMessage(initiateVisitor); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, FormCollection collection) { var eventActivity = _entities.EventActivities.Single(a => a.ID == id); try { //eventActivity.Name = collection.Get("Name"); eventActivity.Remark = collection.Get("Remark"); UpdateModel(eventActivity, "EventActivity"); _entities.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } ////ensure that the model is valid and return the errors back to the view if not. //if (!ModelState.IsValid) // return View(newEventActivity); ////locate the customer in the database and update the model with the views model. //EventActivity thisEventActivity = _entities.EventActivities.Single(a => a.ID == id); //newEventActivity.EventID = thisEventActivity.EventID; //if (TryUpdateModel<EventActivity>(thisEventActivity)) // _entities.SaveChanges(); //else // return View(newEventActivity); ////return to the index page if complete //return RedirectToAction("index"); }
public ActionResult Create(FormCollection collection, Announcement announcement, string Upload) { MembershipUser mu = Membership.GetUser(); try { ImageController ac = new ImageController(); List <UploadFile> uploadFiles = ac.GenerateAttachFileCollectionID(collection, "Announcement"); if (Upload != null) { ImageUploadToServer(); if (uploadFiles != null) { ModelStateSetting(uploadFiles, "Announcement"); } var viewModel = new AnnouncementViewModel { Announcement = announcement, AnnouncementIDs = new List <int>(), }; viewModel.AnnouncementIDs.Add((int)TempData["AnnounceGroupID"]); return(View(viewModel)); } foreach (UploadFile uploadFile in uploadFiles) { AnnouncementUploadFile auf = new AnnouncementUploadFile(); auf.UploadFileID = uploadFile.ID; announcement.AnnouncementUploadFiles.Add(auf); } announcement.AnnouncerID = (Guid)(mu.ProviderUserKey); announcement.AnnounceGroupID = (int)TempData["AnnounceGroupID"]; _entities.AddToAnnouncements(announcement); _entities.SaveChanges(); return(RedirectToAction("Index", new { announceGroupID = (int)TempData["AnnounceGroupID"] })); } catch { return(View()); } }
public static void AddApplicationStatus(SMCHDBEntities _entities, int ID, int statusID) { InternationalGMApplicationStatu InternationalGMApplicationStatus = new InternationalGMApplicationStatu(); InternationalGMApplicationStatus.ApplicationStatusID = statusID; InternationalGMApplicationStatus.ConfirmDate = DateTime.Now.ToUniversalTime().AddHours(8); InternationalGMApplicationStatus.InternationalGMApplicationInfoID = ID; _entities.AddToInternationalGMApplicationStatus(InternationalGMApplicationStatus); _entities.SaveChanges(); }
public ActionResult Create(FormCollection collection, ProductOrder productOrder) { try { _entities.AddToProductOrders(productOrder); _entities.SaveChanges(); productOrder = (from r in _entities.ProductOrders select r).OrderByDescending(x => x.ID).First(); return(RedirectToAction("Index", "Product", new { productOrderID = productOrder.ID, recentOrder = false })); } catch { ProductOrderViewModel viewModel = new ProductOrderViewModel { ProductOrder = productOrder, }; return(View(viewModel)); } }
public ActionResult Create(FormCollection collection, MemberFeePayment memberFeePayment) { memberFeePayment.IMemberID = Guid.Parse(collection.Get("MemberFeePayment.IMemberID")); memberFeePayment.ReceivedDate = DateTime.Now.ToUniversalTime().AddHours(8); if (memberFeePayment.PayMethodID == 1) { memberFeePayment.ToDate = new DateTime(2020, 12, 31); } try { if (_entities.MemberFeePayments.Any(a => a.IMemberID == memberFeePayment.IMemberID && (memberFeePayment.FromDate >= a.FromDate && memberFeePayment.ToDate <= a.ToDate))) { ModelState.AddModelError(string.Empty, "There is a record in this period already for this initiate!"); throw new Exception(); } _entities.AddToMemberFeePayments(memberFeePayment); _entities.SaveChanges(); SaveLatestMemberFeeToDateToMemberInfo(memberFeePayment.IMemberID); return(RedirectToAction("Index")); } catch { var viewModel = new MemberFeePaymentViewModel { MemberFeePayment = memberFeePayment, MemberInfos = BlackListMemberController.GetMemberNameSelectList(memberFeePayment.IMemberID), PayMethod = _entities.PayMethods.ToList(), }; //var viewModel = GetMemberFeePaymentViewModel(); return(View(viewModel)); } }
private void AddGroupMeditationItem(DateTime dt, double startTime, double duration, int InitiateTypeID) { GroupMeditation gm = new GroupMeditation(); gm.InitiateTypeID = InitiateTypeID; gm.StartDateTime = dt.Date.AddHours(startTime); gm.EndDateTime = gm.StartDateTime.AddHours(duration); if (!_entities.GroupMeditations.Any(a => a.StartDateTime == gm.StartDateTime)) { _entities.AddToGroupMeditations(gm); _entities.SaveChanges(); } }
public ActionResult Edit(int eventID, int eventActivityID, FormCollection collection) { var eventActivity = _entities.EventPrices.Single(a => a.EventID == eventID && a.EventActivityID == eventActivityID); try { eventActivity.UnitPrice = decimal.Parse(collection.Get("UnitPrice")); UpdateModel(eventActivity, "EventPrice"); _entities.SaveChanges(); return(RedirectToAction("Index", new { eventID = eventActivity.EventID })); } catch { return(View()); } }
public ActionResult OrderSubmit(int productOrderID, int orderStatusID) { List <MemberOrder> memberOrders = (from r in _entities.MemberOrders where r.ProductOrderID == productOrderID && r.OrderStatusID == orderStatusID select r).ToList(); if (orderStatusID == 1) { DateTime now = DateTime.Now.ToUniversalTime().AddHours(8); now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0); foreach (MemberOrder memberOrder in memberOrders) { memberOrder.OrderStatusID = 2; memberOrder.SubmitDateTime = now; _entities.SaveChanges(); } } return(RedirectToAction("IndexByMemberOrder", new { productOrderID = productOrderID, orderStatusID = 2 })); }
public void GenerateEventSchedules(Event curEvent) { NewEventPrice(curEvent, 5, 10M); EventSchedule eventSchedule = new EventSchedule(); eventSchedule.DateTimeFrom = curEvent.StartDateTime; eventSchedule.EventActivityID = 5; // lunch TimeSpan temp = curEvent.EndDateTime - curEvent.StartDateTime; eventSchedule.ScheduleOffsetID = (from r in _entities.ScheduleOffsets where r.OffsetHours == temp.TotalHours select r.ID).FirstOrDefault(); //AddVolunteerJob(2, eventSchedule, "Clean"); //AddVolunteerJob(1, eventSchedule, "Video"); eventSchedule.EventID = curEvent.ID; _entities.AddToEventSchedules(eventSchedule); _entities.SaveChanges(); }
public void AddToProductOrders(FormCollection collection, int productOrderID) { ProductOrder productOrder = _entities.ProductOrders.SingleOrDefault(a => a.ID == productOrderID); List <ProductOrderDetail> productOrderDetails = _entities.ProductOrderDetails.Where(a => a.ProductOrderID == productOrderID).ToList(); List <int> productIDs = productOrderDetails.Select(a => a.ProductID).ToList(); //if (selectedProductIDs == null) //{ // List<int> temp = new List<int>(); // foreach (Product product in viewModel) // { // temp.Add(product.ID); // } // selectedProductIDs = temp.AsEnumerable(); //} string[] keys = collection.AllKeys; for (int i = 1; i < keys.Length - 1; i++) //Remove DropDownList [0] and buttom [Length] { string temp = collection.Get(keys[i].ToString()); int productID = int.Parse(keys[i]); if (!string.IsNullOrEmpty(temp) && temp.ToLower().StartsWith("true") && !productIDs.Contains(productID)) { ProductOrderDetail pod = new ProductOrderDetail(); pod.ProductID = productID; productOrder.ProductOrderDetails.Add(pod); } else if (!string.IsNullOrEmpty(temp) && temp.ToLower().StartsWith("false") && productIDs.Contains(productID)) { ProductOrderDetail pod = _entities.ProductOrderDetails.SingleOrDefault(a => a.ProductID == productID && a.ProductOrderID == productOrderID); _entities.DeleteObject(pod); } } UpdateModel(productOrder, "ProductOrder"); _entities.SaveChanges(); }
static private void GetCheckInOutAccessTableData(string[] args) { SMCHDBEntities _entities = new SMCHDBEntities(); string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Program Files\\att2008\\att2000.mdb"; string strSql = "SELECT CHECKINOUT.CHECKTIME, USERINFO.Badgenumber FROM (CHECKINOUT INNER JOIN USERINFO ON CHECKINOUT.USERID = USERINFO.USERID) "; OleDbConnection con = new OleDbConnection(conString); DataTable AttendanceTable = new DataTable(); System.Console.WriteLine("Opening MDB connection..."); con.Open(); OleDbDataAdapter dAdapter = new OleDbDataAdapter(); dAdapter.SelectCommand = new OleDbCommand(strSql, con); dAdapter.Fill(AttendanceTable); con.Close(); System.Console.WriteLine("Data loaded from MDB file. Updating database, please wait..."); // get latest time in GroupMeditationAttendance table DateTime latestGroupMeditationAttendanceDB = _entities.GroupMeditationAttendances.OrderByDescending(a => a.CheckInTime).Select(a => a.CheckInTime).FirstOrDefault(); if (latestGroupMeditationAttendanceDB < new DateTime(2011, 12, 1) || args.Length == 1 && args[0].ToLower() == "all") { latestGroupMeditationAttendanceDB = new DateTime(2011, 12, 1); } else { latestGroupMeditationAttendanceDB = latestGroupMeditationAttendanceDB.AddDays(-3); } // Filter old record and no member person var attendanceList = AttendanceTable.AsEnumerable().Where( a => a.Field <DateTime>("CHECKTIME") >= latestGroupMeditationAttendanceDB); List <int> memberNoList = _entities.MemberInfos.Where(a => a.MemberNo.HasValue).Select(a => a.MemberNo.Value).ToList(); foreach (DataRow dr in attendanceList) { DateTime checkInTime = (DateTime)dr["CHECKTIME"]; int memberNo = int.Parse((string)dr["Badgenumber"]); if (!memberNoList.Contains(memberNo)) { continue; } //System.Console.WriteLine("Uploading record of member " + memberNo.ToString() + " at " + checkInTime.ToString()); Guid memberID = _entities.MemberInfos.SingleOrDefault(a => a.MemberNo == memberNo).MemberID; DateTime checkInTimeStart = checkInTime.AddMinutes(90 + 15); DateTime checkInTimeEnd = checkInTime.AddMinutes(-15); //if (_entities.Events.Any(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTime)) if (_entities.Events.Any(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTimeEnd)) { //int eventID = _entities.Events.Where(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTime).FirstOrDefault().ID; Event aEvent = _entities.Events.Where(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTimeEnd).FirstOrDefault(); if (!_entities.EventRegistrations.Any(a => a.EventID == aEvent.ID && a.MemberID == memberID)) { EventRegistration eventRegistration = new EventRegistration(); eventRegistration.MemberID = memberID; eventRegistration.EventID = aEvent.ID; eventRegistration.SignTime = checkInTime; _entities.AddToEventRegistrations(eventRegistration); _entities.SaveChanges(); System.Console.WriteLine("Uploading" + aEvent.Title + " MemberNo: " + memberNo.ToString() + " at " + checkInTime.ToString()); //System.Console.WriteLine("Updated Event checkin"); continue; } } //if (_entities.GroupMeditations.Any(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTime)) if (_entities.GroupMeditations.Any(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTimeEnd)) { //int groupMeditaionID = _entities.GroupMeditations.Where(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTime).FirstOrDefault().ID; int groupMeditaionID = _entities.GroupMeditations.Where(a => a.StartDateTime <= checkInTimeStart && a.StartDateTime >= checkInTimeEnd).FirstOrDefault().ID; if (!_entities.GroupMeditationAttendances.Any(a => a.GroupMeditationID == groupMeditaionID && a.MemberID == memberID)) { GroupMeditationAttendance groupMeditationAttendance = new GroupMeditationAttendance(); groupMeditationAttendance.MemberID = memberID; groupMeditationAttendance.GroupMeditationID = groupMeditaionID; groupMeditationAttendance.CheckInTime = checkInTime; _entities.AddToGroupMeditationAttendances(groupMeditationAttendance); _entities.SaveChanges(); System.Console.WriteLine("Uploading GM: MemberNo " + memberNo.ToString() + " at " + checkInTime.ToString()); } } } }
public ActionResult Create(OrdinaryMemberInfo OrdinaryMemberInfo, PublicMemberInfo PublicMemberInfo, FormCollection collection) { //SMCHDBLocalEntities _localEntities = new SMCHDBLocalEntities(); AccountController ac = new AccountController(); ac.InitializePublic(HttpContext.Request.RequestContext); try { Guid memberID = Guid.Empty; string errorString = ac.RegisterOrdinaryMember(PublicMemberInfo.Name, PublicMemberInfo.Email, ref memberID); if (!string.IsNullOrEmpty(errorString)) { ViewData["errorMsg"] = errorString; throw new Exception(); } if (OrdinaryMemberInfo.MemberFeePayByID == 1) { PublicMemberInfo.MemberFeeExpiredDate = new DateTime(2020, 12, 31); } MemberInfo memberInfo = GetMemberInfo(PublicMemberInfo, memberID); _entities.AddToMemberInfos(memberInfo); _entities.SaveChanges(); SetBackToNull(OrdinaryMemberInfo); //OrdinaryMemberInfo.IMemberID = memberID; //_localEntities.AddToOrdinaryMemberInfos(OrdinaryMemberInfo); //_localEntities.SaveChanges(); MembershipUser newUser = Membership.GetUser(memberInfo.MemberID); if (newUser.Email.Trim() != "*****@*****.**") { HomeController hc = new HomeController(); try { hc.sendUserEmail(newUser); } catch { } } return(RedirectToAction("Index")); } catch { //Invalid - redisplay with errors var viewModel = new OrdinaryMemberViewModel { OrdinaryMemberInfo = OrdinaryMemberInfo, PublicMemberInfo = PublicMemberInfo, //Nationality = _localEntities.Nationalities.ToList(), Gender = _entities.Genders.ToList(), //Race = _localEntities.Races.ToList(), //EmploymentStatus = _localEntities.EmploymentStatuses.ToList(), PayMethod = _entities.PayMethods.ToList(), InitiateType = _entities.InitiateTypes.Where(a => a.ID <= 2).ToList(), }; DefaultSettings(viewModel); return(View(viewModel)); } }
public ActionResult Create(FormCollection collection, Event Event, string Upload) { MembershipUser mu = Membership.GetUser(); try { ValidateEvent(Event); if (!ModelState.IsValid) { throw new Exception();//ModelState["Event.StartDateTime"].Errors.Last().ErrorMessage); } ImageController ac = new ImageController(); List <UploadFile> uploadFiles = ac.GenerateAttachFileCollectionID(collection, "Event"); if (Upload != null) { ImageUploadToServer(); if (uploadFiles != null) { ModelStateSetting(uploadFiles, "Event"); } var viewModel = new EventViewModel() { Event = Event, Locations = _entities.Locations.ToList(), EventTypes = (from r in _entities.EventTypes where r.ID != 2 && r.ID != 3 select r).ToList(), }; return(View(viewModel)); } foreach (UploadFile uploadFile in uploadFiles) { EventUploadFile auf = new EventUploadFile(); auf.UploadFileID = uploadFile.ID; Event.EventUploadFiles.Add(auf); } Event.OrganizerNameID = (Guid)(mu.ProviderUserKey); //GenerateEventPrices(Event); _entities.AddToEvents(Event); _entities.SaveChanges(); if (Event.EventTypeID == 1) { Event = (from r in _entities.Events select r).OrderByDescending(x => x.ID).First(); TempData["Event"] = Event; return(RedirectToAction("ScheduleModelSelect", "EventSchedule")); } else { EventScheduleController esc = new EventScheduleController(); esc.GenerateEventSchedules(Event); return(RedirectToAction("Index")); } } catch { var viewModel = new EventViewModel() { Event = new Event(), Locations = _entities.Locations.ToList(), EventTypes = (from r in _entities.EventTypes where r.ID != 2 && r.ID != 3 select r).ToList(), }; //viewModel.LocalRetreatScheduleModelSelectLists = GetScheduleSelectLists(); return(View(viewModel)); } }