public void EditEvent(ICommingEvent commingEvent, string eventUserEmail, string eventLink, string googleEventId, string eventName, DateTime eventDate, DateTime eventEndDate, string eventCity, string eventPlace, string eventLead, bool isApproved, bool isOnline) { Check.Argument.IsNotNull(commingEvent, "CommingEvent"); if (!string.IsNullOrEmpty(eventUserEmail)) { commingEvent.Email = eventUserEmail; } if (!string.IsNullOrEmpty(eventLink)) { commingEvent.EventLink = eventLink; } if (!string.IsNullOrEmpty(eventName)) { commingEvent.EventName = eventName; } commingEvent.EventDate = eventDate; commingEvent.EventEndDate = eventEndDate; commingEvent.EventPlace = eventPlace; commingEvent.EventCity = eventCity; commingEvent.EventLead = eventLead; commingEvent.Email = eventUserEmail; commingEvent.GoogleEventId = googleEventId; commingEvent.IsApproved = isApproved; commingEvent.IsOnline = isOnline; }
public void EditEvent(ICommingEvent commingEvent, string eventUserEmail, string eventLink, string eventName, DateTime eventDate, string eventPlace, string eventLead, bool isApproved) { Check.Argument.IsNotNull(commingEvent, "CommingEvent"); if (!string.IsNullOrEmpty(eventUserEmail)) { commingEvent.Email = eventUserEmail; } if (!string.IsNullOrEmpty(eventLink)) { commingEvent.EventLink = eventLink; } if (!string.IsNullOrEmpty(eventName)) { commingEvent.EventName = eventName; } commingEvent.EventDate = eventDate; commingEvent.EventPlace = eventPlace; commingEvent.EventLead = eventLead; commingEvent.Email = eventUserEmail; commingEvent.IsApproved = isApproved; }
public void Remove(ICommingEvent entity) { Check.Argument.IsNotNull(entity, "entity"); CommingEvent commingEvent = (CommingEvent)entity; base.Remove(commingEvent); }
public ActionResult GetEvent(string id) { id = id.NullSafe(); JsonViewData viewData = Validate <JsonViewData>( new Validation(() => string.IsNullOrEmpty(id), "Identyfikator wydarzenia nie może być pusty."), new Validation(() => id.ToGuid().IsEmpty(), "Niepoprawne id wydarzenia."), new Validation(() => !IsCurrentUserAuthenticated, "Nie jesteś zalogowany."), new Validation(() => !CurrentUser.CanModerate(), "Nie masz praw do woływania tej metody.") ); if (viewData == null) { try { ICommingEvent commingEvent = _commingEventRepository.FindById(id.ToGuid()); // findById do zaimplementowania if (commingEvent == null) { viewData = new JsonViewData { errorMessage = "Podane wydarzenie nie istnieje." }; } else { return(Json( new { eventId = commingEvent.Id.Shrink(), eventLink = commingEvent.EventLink, eventName = commingEvent.EventName, eventDate = commingEvent.EventDate.ToString("dd-MM-yyyy HH:mm"), eventEndDate = commingEvent.EventEndDate?.ToString("dd-MM-yyyy HH:mm"), eventCity = commingEvent.EventCity, eventPlace = commingEvent.EventPlace, eventLead = commingEvent.EventLead, eventUserEmail = commingEvent.Email, isApproved = commingEvent.IsApproved, isOnline = commingEvent.IsOnline } )); } } catch (Exception e) { Log.Exception(e); viewData = new JsonViewData { errorMessage = FormatStrings.UnknownError.FormatWith("pobierania wydarzenia") }; } } return(Json(viewData)); }
public ActionResult DeleteEvent(string id) { id = id.NullSafe(); JsonViewData viewData = Validate <JsonViewData>( new Validation(() => !CurrentUser.CanModerate(), "Nie masz praw do wołania tej metody."), new Validation(() => string.IsNullOrEmpty(id), "Identyfikator reklamy nie może być pusty."), new Validation(() => id.ToGuid().IsEmpty(), "Niepoprawny identyfikator wydarzenia."), new Validation(() => !IsCurrentUserAuthenticated, "Nie jesteś zalogowany.") ); if (viewData == null) { try { using (IUnitOfWork unitOfWork = UnitOfWork.Begin()) { ICommingEvent commingEvent = _commingEventRepository.FindById(id.ToGuid()); if (commingEvent == null) { viewData = new JsonViewData { errorMessage = "Wydarzenie nie istnieje." }; } else { _commingEventRepository.Remove(commingEvent); unitOfWork.Commit(); if (!string.IsNullOrEmpty(commingEvent.GoogleEventId)) { _googleService.DeleteEvent(commingEvent.GoogleEventId); } viewData = new JsonViewData { isSuccessful = true }; } } } catch (Exception e) { Log.Exception(e); viewData = new JsonViewData { errorMessage = FormatStrings.UnknownError.FormatWith("usuwania wydarzenia") }; } } return(Json(viewData)); }
private static CommingEventViewData CreateCommingEventsViewData(ICommingEvent x) { return(new CommingEventViewData { EventLink = x.EventLink, EventName = x.EventName, EventDate = x.EventDate, Id = x.Id.Shrink(), EventPlace = x.EventPlace, EventLead = x.EventLead, Email = x.Email, IsApproved = x.IsApproved.GetValueOrDefault(), }); }
public ActionResult EditEvent(EventViewData model) { if (model.EventLead == null) { model.EventLead = "Brak opisu"; } JsonViewData viewData = Validate <JsonViewData>( new Validation(() => string.IsNullOrEmpty(model.EventLink.NullSafe()), "Link wydarzenia nie może być pusty."), new Validation(() => string.IsNullOrEmpty(model.EventName.NullSafe()), "Tytuł wydarzenia nie może być pusty."), new Validation(() => !model.EventUserEmail.NullSafe().IsEmail(), "Niepoprawny adres e-mail."), new Validation(() => CurrentUser.IsAdministrator() == false, "Nie możesz edytować tego wydarzenia."), new Validation(() => model.Id.NullSafe().ToGuid().IsEmpty(), "Nieprawidłowy identyfikator wydarzenia."), new Validation(() => !model.EventEndDate.IsLaterThan(model.EventDate), "Nieprawidłowa data zakończenia wydarzenia.") ); if (viewData == null) { try { using (IUnitOfWork unitOfWork = UnitOfWork.Begin()) { ICommingEvent commingEvent = _commingEventRepository.FindById(model.Id.ToGuid()); var eventApproveStatus = CurrentUser.IsAdministrator() && model.IsApproved; if (commingEvent == null) { viewData = new JsonViewData { errorMessage = "Podane wydarzenie nie istnieje." }; } else { if (model.IsApproved) { if (string.IsNullOrEmpty(commingEvent.GoogleEventId)) { var upcomingEvent = new CommingEvent(commingEvent.EventName, commingEvent.EventLink, commingEvent.GoogleEventId, commingEvent.EventDate, commingEvent.EventEndDate.Value, commingEvent.EventCity, commingEvent.EventPlace, commingEvent.EventLead, model.IsOnline); model.GoogleEventId = _googleService.EventApproved(upcomingEvent); } else { var upcomingEvent = new CommingEvent(model.EventName, model.EventLink, commingEvent.GoogleEventId, model.EventDate, model.EventEndDate, model.EventCity, model.EventPlace, model.EventLead, model.IsOnline); model.GoogleEventId = _googleService.EditEvent(upcomingEvent); } } else if (!string.IsNullOrEmpty(commingEvent.GoogleEventId)) { _googleService.DeleteEvent(commingEvent.GoogleEventId); model.GoogleEventId = null; } _commingEventRepository.EditEvent( commingEvent, model.EventUserEmail.NullSafe(), model.EventLink.NullSafe(), model.GoogleEventId, model.EventName.NullSafe(), model.EventDate, model.EventEndDate, model.EventCity, model.EventPlace, model.EventLead, eventApproveStatus, model.IsOnline ); unitOfWork.Commit(); viewData = new JsonViewData { isSuccessful = true }; } } } catch (Exception e) { Log.Exception(e); viewData = new JsonViewData { errorMessage = FormatStrings.UnknownError.FormatWith("edycji wydarzenia.") }; } } return(Json(viewData)); }