/// <summary> /// Constructor of the view model /// </summary> /// <param name="currentPage">Page of the view mode</param> /// <param name="userServices">Services for the "User" table</param> /// <param name="alertServices">Services for the "Alert" table</param> /// <param name="materialServices">Services for the "Material" table</param> /// <param name="productServices">Services for the "Product" table</param> /// <param name="materialsProductServices">Services for the "MaterialProduct" table</param> /// <param name="saleServices">Services for the "Sale" table</param> /// <param name="countAlerts">Number of alerts</param> public BoardViewModel(BoardWindow currentPage, UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, int countAlerts) { CurrentPage = currentPage; CurrentUserName = $"Welcome {AppSettings.CurrentUser.Login} {(AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? "(admin)" : "")} !"; CurrentUserAdmin = AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? Visibility.Visible : Visibility.Hidden; CurrentUserLambda = AppSettings.CurrentUser.Role == ERole.User.ToString() ? Visibility.Visible : Visibility.Hidden; UserServices = userServices; AlertServices = alertServices; MaterialServices = materialServices; ProductServices = productServices; MaterialsProductServices = materialsProductServices; SaleServices = saleServices; BadgeAlert = countAlerts; GoBackCommand = new CommandHandler(GoBack, () => true); GoToAddUserCommand = new CommandHandler(GoToAddUser, () => true); GoToAlertsCommand = new AsyncCommand(GoToAlerts, () => true); GoToListingElementsCommand = new AsyncCommand(GoToListingElements, () => true); GoToStatisticsCommand = new AsyncCommand(GoToStatistics, () => true); GoToUpdateStockCommand = new AsyncCommand(GoToUpdateStock, () => true); GoToAddElementCommand = new AsyncCommand(GoToAddElement, () => true); }
/// <summary> /// Constructor of the view model /// </summary> /// <param name="currentPage">Page of the view mode</param> /// <param name="userServices">Services for the "User" table</param> /// <param name="alertServices">Services for the "Alert" table</param> /// <param name="materialServices">Services for the "Material" table</param> /// <param name="productServices">Services for the "Product" table</param> /// <param name="materialsProductServices">Services for the "MaterialProduct" table</param> /// <param name="saleServices">Services for the "Sale" table</param> /// <param name="products">List of products</param> /// <param name="materials">List of materials</param> /// <param name="materialsProducts">List of materials product</param> public ListingElementsViewModel(ListingElementsWindow currentPage, UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, List <Product> products, List <Material> materials, List <MaterialsProduct> materialsProducts) { CurrentUserName = $"Welcome {AppSettings.CurrentUser.Login} {(AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? "(admin)" : "")} !"; CurrentPage = currentPage; UserServices = userServices; AlertServices = alertServices; MaterialServices = materialServices; ProductServices = productServices; MaterialsProductServices = materialsProductServices; SaleServices = saleServices; Products = products; Materials = materials; MaterialsProducts = materialsProducts; GenerateDatagrid(); GoBackCommand = new AsyncCommand(GoBack, () => true); }
private void LoadAlerts() { var list = new List <HRR.Core.Domain.Interfaces.IAlert>(); if (_cache.Retrieve <List <HRR.Core.Domain.Interfaces.IAlert> >(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_AlertsFeed") == null) { list = new AlertServices().GetAlertsByDueDate(DateTime.Now.AddDays(21)).ToList <HRR.Core.Domain.Interfaces.IAlert>(); _cache.Store(SecurityContextManager .Current .CurrentUser.ID.ToString() + "_AlertsFeed", list); } else { list = _cache.Retrieve <List <HRR.Core.Domain.Interfaces.IAlert> >(SecurityContextManager .Current .CurrentUser.ID.ToString() + "_AlertsFeed"); } if (list.Count < 1) { divAlertsMessage.Visible = true; } else { divAlertsMessage.Visible = false; } dlAlerts.DataSource = list; dlAlerts.DataBind(); }
private async void OnSelectedContact(Contact contact) { if (contact != null) { await AlertServices.AlertAsync("Contact", $"Número de teléfono de {contact.Name} es {string.Format("(000)-000-0000", contact.PhoneNumber)}"); } }
public JsonResult Get(PagerModel pager, AlertModel filters) { AlertServices service = new AlertServices(); filters.To = SessionWeb.User.PersonId; var collection = service.Get(pager, filters); return(Json(collection, JsonRequestBehavior.AllowGet)); }
/// <summary> /// This window is for adding a element /// </summary> /// <param name="userServices"></param> /// <param name="alertServices"></param> /// <param name="materialServices"></param> /// <param name="productServices"></param> /// <param name="materialsProductServices"></param> /// <param name="saleServices"></param> /// <param name="materials"></param> public AddElementWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, List <Material> materials) { InitializeComponent(); DataContext = new AddElementViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, materials); }
public JsonResult MarkAsReaded(AlertModel alert) { AlertServices alertServices = new AlertServices(); alert.To = SessionWeb.User.PersonId; AlertModel resp = alertServices.MarkAsReaded(alert); resp = resp ?? new AlertModel(); return(Json(resp)); }
public UpdateStockWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, List <Product> products, List <Material> materials) { InitializeComponent(); DataContext = new UpdateStockViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, products, materials); }
public ActionResult Total() { AlertServices alertServices = new AlertServices(); PagerModel pager = new PagerModel(0, 1, "", ""); AlertModel filter = new AlertModel(); filter.Status = (int)AlertStatus.New; filter.To = SessionWeb.User.PersonId; alertServices.Get(pager, filter); string res = pager.TotalRecords == 0 ? string.Format("<span id='alertTotal' class='badge badge-pink noti-icon-badge'>{0}</span>", pager.TotalRecords) : string.Format("<span id='alertTotal' class='badge badge-pink noti-icon-badge'>{0}</span>", pager.TotalRecords); return(Content(res)); }
private void LoadAlerts() { var list = new AlertServices().GetAlertsByDueDate(DateTime.Now.AddDays(21)); if (list.Count < 1) { divAlerts.Visible = true; } else { divAlerts.Visible = false; } dlAlerts.DataSource = list; dlAlerts.DataBind(); }
private async void OnAddContact() { if (!string.IsNullOrEmpty(NewContact.Name) && NewContact.PhoneNumber.Length == 10) { NewContact.FirstLetterName = NewContact.Name.Substring(0, 1).ToUpper(); Contacts.Add(NewContact); await AlertServices.AlertAsync("New contact added", $"{NewContact.Name} fue agregado como contacto"); await NavigationServices.NonModalPop(); } else { await AlertServices.AlertAsync("Error", "Faltan datos por llenar, favor revise e intente de nuevo"); } }
private async void GetActiveTeams() { var teams = await NbaApiServices.GetTeams(); if (teams.GetType().Name == "Teams") { if (teams != null) { TeamList = new ObservableCollection <Team>(teams.League.Standard); InternetConnection = true; } } else { InternetConnection = false; await AlertServices.AlertAsync("Error", "No hay conexión a internet"); } }
private void SendNotificationsInvite(int?personId, int?companyId) { AlertServices alertServices = new AlertServices(); CompanyServices csrv = new CompanyServices(); var company = csrv.Get(new CompanyModel() { CompanyId = companyId }).FirstOrDefault(); AlertModel alert = alertServices.GetWithValues(2, null); alert.To = personId; alert.Body = string.Format(alert.Body, company.CompanyName); alertServices.InsUpd(alert); var context = GlobalHost.ConnectionManager.GetHubContext <AlertHub>(); context.Clients.Group(string.Format("P{0}", personId.ToString())) .newAlert(alert); }
/// <summary> /// Constructor of the view model /// </summary> /// <param name="currentPage">Page of the view mode</param> /// <param name="userServices">Services for the "User" table</param> /// <param name="alertServices">Services for the "Alert" table</param> /// <param name="materialServices">Services for the "Material" table</param> /// <param name="productServices">Services for the "Product" table</param> /// <param name="materialsProductServices">Services for the "MaterialProduct" table</param> /// <param name="saleServices">Services for the "Sale" table</param> /// <param name="countBySite">Data to the graphic "Count Sales By Site"</param> /// <param name="evolutionByMonth">Data to the graphic "Evolution by month"</param> /// <param name="moneyEarned">Money earned until the start</param> /// <param name="moneyEarnedByYear">Data to the graphic "Money by year"</param> public StatisticsViewModel(StatisticsWindow currentPage, UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, Dictionary <string, int> countBySite, List <Tuple <string, int, int, int> > evolutionByMonth, float moneyEarned, Dictionary <int, float> moneyEarnedByYear) { CurrentPage = currentPage; CurrentUserName = $"Welcome {AppSettings.CurrentUser.Login} {(AppSettings.CurrentUser.Role == ERole.Administrator.ToString() ? "(admin)" : "")} !"; UserServices = userServices; AlertServices = alertServices; MaterialServices = materialServices; ProductServices = productServices; MaterialsProductServices = materialsProductServices; SaleServices = saleServices; GenerateCountSalesBySite(countBySite); GenerateEvolutionByMonth(evolutionByMonth); GenerateMoneyEarnedByYear(moneyEarnedByYear); MoneyEarned = $"{moneyEarned:C}"; GoBackCommand = new AsyncCommand(GoBack, () => true); }
public JsonResult GetTable(DatatableModel dt, AlertModel filters) { filters.To = SessionWeb.User.PersonId; AlertServices services = new AlertServices(); PagerModel pager = dt.ToPager(); filters.Body = dt.sSearch; var collection = services.Get(pager, filters); return(Json(new { status = UI.Status.Success, sEcho = dt.sEcho, iTotalRecords = pager.TotalRecords, iTotalDisplayRecords = pager.TotalRecords, aaData = collection }, JsonRequestBehavior.AllowGet)); }
private async void OnEditContact() { if (!string.IsNullOrEmpty(ContactToEdit.Name) && ContactToEdit.PhoneNumber.Length == 10) { ContactToEdit.FirstLetterName = ContactToEdit.Name.Substring(0, 1).ToUpper(); Contacts.Remove(OldContact); Contacts.Add(ContactToEdit); await AlertServices.AlertAsync($"Edit contact", $"{ContactToEdit.Name} was edited"); await NavigationServices.ModalPop(); } else { await AlertServices.AlertAsync("Error", "Faltan datos por llenar, favor revise e intente de nuevo"); } }
public JsonResult Send(int?PersonId) { PersonId = PersonId ?? SessionWeb.User.PersonId; AlertServices alertServices = new AlertServices(); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("Username", SessionWeb.User.UserName); AlertModel alert = alertServices.GetWithValues(1, values); alert.To = PersonId; alertServices.InsUpd(alert); var context = GlobalHost.ConnectionManager.GetHubContext <AlertHub>(); context.Clients.Group(string.Format("P{0}", PersonId.ToString())) .newAlert(alert); return(Json("{}")); }
private async void GetActivePlayers() { var players = await NbaApiServices.GetNbaPlayers(); if (players.GetType().Name == "Players") { if (players != null) { List <Player> activlePlayersList = players.League.Standard.Where(player => player.IsActive == true).ToList(); ActivePlayers = new ObservableCollection <Player>(activlePlayersList); AllActivePlayers = new ObservableCollection <Player>(activlePlayersList); InternetConnection = true; } } else { InternetConnection = false; await AlertServices.AlertAsync("Error", "No hay conexión a internet"); } }
public string GetAlertByDueDate() { var list = new AlertServices().GetAlertsByDueDate(DateTime.Now.AddDays(21)); string s = "["; foreach (var item in list) { switch (item.ItemType) { case AlertType.GOAL: var g = (HRR.Core.Domain.Goal)item; s += "{\"avatar\":\"" + g.EnteredForRef.AvatarPath + "\",\"enteredfor\":\"<a style='vertical-align: top;' href='/People/" + g.EnteredForRef.Email + "'>" + g.EnteredForRef.Name + "</a>" + "\",\"alerttitle\":\"goal - <a style='vertical-align: top;' href='/Goals/" + g.ID.ToString() + "'>" + g.Title + "</a>" + "\",\"duedate\":\"" + g.DueDate.ToShortDateString() + "\"},"; break; case AlertType.MILESTONE: var m = (HRR.Core.Domain.GoalMilestone)item; s += "{\"avatar\":\"" + m.EnteredForRef.AvatarPath + "\",\"enteredfor\":\"<a style='vertical-align: top;' href='/People/" + m.EnteredForRef.Email + "'>" + m.EnteredForRef.Name + "</a>" + "\",\"alerttitle\":\"milestone - <a style='vertical-align: top;' href='/Goals/" + m.GoalRef.ID.ToString() + "'>" + m.Title + "</a>" + "\",\"duedate\":\"" + m.DueDate.ToShortDateString() + "\"},"; break; case AlertType.REVIEW: var r = (HRR.Core.Domain.Review)item; s += "{\"avatar\":\"" + r.EnteredForRef.AvatarPath + "\",\"enteredfor\":\"<a style='vertical-align: top;' href='/People/" + r.EnteredForRef.Email + "'>" + r.EnteredForRef.Name + "</a>" + "\",\"alerttitle\":\"review - <a style='vertical-align: top;' href='/Reviews/" + r.ID.ToString() + "'>" + r.Title + "</a>" + "\",\"duedate\":\"" + r.DueDate.ToShortDateString() + "\"},"; break; } //s += "{\"name\":\"" + item.EnteredForRef.LastName + "\",\"commentType\":\"" + item.CommentType.ToString() + "\",\"message\":\"" + item.Message + "\",\"enteredBy\":\"" + item.EnteredByRef.LastName + "\"},"; } return(s.Remove(s.Length - 1, 1) + "]"); }
public ActionResult LastAlerts() { AlertServices alertServices = new AlertServices(); PagerModel pager = new PagerModel(0, 8, "CreatedAt", "desc"); AlertModel filter = new AlertModel(); filter.Status = (int)AlertStatus.New; filter.To = SessionWeb.User.PersonId; List <AlertModel> lstAlert = alertServices.Get(pager, filter); string resp = ""; foreach (AlertModel alert in lstAlert) { resp += string.Format("<a href='javascript:Main.MarkAsReaded({3});' id='alert_{3}' class='dropdown-item notify-item alert-item'>" + "<div class='notify-icon bg-info'><i class='mdi {1}'></i></div>" + "<p class='notify-details' style='white-space: normal'><small>{0}</small><small class='text-muted'>{2}</small></p>" + "</a>", alert.Body, alert.Icon, alert.TimeAgo, alert.AlertId); } return(Content(resp)); }
/// <summary> /// Method to update the alert /// </summary> public void UpdateAlerts() { var childrens = CurrentPage.ListAlerts.Children; List <Alert> updatedAlerts = new List <Alert>(); foreach (Card chidren in childrens) { Grid grid = chidren.Content as Grid; if ((grid?.Children[1] as Grid)?.Children[0] is CheckBox checkBox) { var id = int.Parse(checkBox.Name.Split('_')[1]); var alert = Alerts.First(x => x.Id == id); if (checkBox.IsChecked != null) { alert.IsDismiss = (bool)checkBox.IsChecked; } updatedAlerts.Add(alert); } } AlertServices.UpdateAlerts(updatedAlerts); }
/// <summary> /// Offer from Project to Vessel /// Validations /// Insert offer with Status NEW /// Send alert to Vessel company owners /// Send mail to Vessel company owners /// </summary> /// <param name="offer"></param> /// <returns></returns> public RequestResult <List <AlertModel> > InsComplete(OfferModel offer) { RequestResult <List <AlertModel> > resp = new RequestResult <List <AlertModel> >() { Status = Status.Success }; OfferDA offerDA = new OfferDA(); VesselServices vesselServices = new VesselServices(); PersonServices personServices = new PersonServices(); AlertServices alertServices = new AlertServices(); List <AlertModel> lstAlertToSend = new List <AlertModel>(); MailServices MailServ = new MailServices(); ITemplate factory = new TemplateMessagesFactory(); TransactionOptions scopeOptions = new TransactionOptions(); ////scopeOptions.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, scopeOptions)) { try { if (offer.Vessel.VesselId == null) { throw new Exception("VesselId REQUIRED"); } if (offer.Project.ProjectId == null) { throw new Exception("ProjectId REQUIRED"); } if (offer.ProjectAdmin.PersonId == null) { throw new Exception("ProjectAdmin.PersonId REQUIRED"); } OfferModel val = new OfferModel(); List <OfferModel> lstVal = new List <OfferModel>(); val.Project.ProjectId = offer.Project.ProjectId; val.Vessel.VesselId = offer.Vessel.VesselId; lstVal = Get(val); if (lstVal.Count > 0) { throw new Exception("STATUS_NOT_VALID"); } VesselModel vessel = new VesselModel(); vessel.VesselId = offer.Vessel.VesselId; vessel = vesselServices.Get(vessel).FirstOrDefault(); // Insert offer with Status NEW var respOffer = offerDA.InsUpd(offer); if (respOffer.Status != Status.Success) { throw new Exception(respOffer.Message); } // Send alert to Vessel company owners //Listado de los usuarios de una compañía UserPersonModel person = new UserPersonModel(); person.CompanyId = vessel.Company.CompanyId; List <UserPersonModel> lst = personServices.getUserPerson(person); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("IMO", vessel.Imo); values.Add("VESSELNAME", vessel.Name); AlertModel alert = alertServices.GetWithValues(6, values); SystemVariableServices SVS = new SystemVariableServices(); Dictionary <string, string[]> param = new Dictionary <string, string[]>(); string EgulfUrl = SVS.GetSystemVariableValue("EgulfWeb"); param.Add("{Enfasis}", new string[] { vessel.Imo, vessel.Name }); param.Add("{Btn_url}", new string[] { EgulfUrl }); foreach (UserPersonModel personItem in lst) { AlertModel alertAux = alert.Clone(); alertAux.To = personItem.PersonId; lstAlertToSend.Add(alertAux); MailServ.SendMail(factory.GetTemplate(personItem.Email, "VesselOfferReceived", param)); } var respAlert = alertServices.InsUpd(lstAlertToSend); if (respAlert != null) { throw new Exception(respAlert.Message); } resp.Data = lstAlertToSend; ts.Complete(); } catch (Exception ex) { ts.Dispose(); resp = new RequestResult <List <AlertModel> >() { Status = Status.Error, Message = ex.Message }; Elmah.ErrorSignal.FromCurrentContext().Raise(ex); throw ex; } } return(resp); }
public ActionResult OfferTransaction(string id, OfferModel offer) { RequestResult <List <AlertModel> > result = new RequestResult <List <AlertModel> >() { Status = Status.Success }; List <AlertModel> lstAlertToProjectCompany = new List <AlertModel>(); List <AlertModel> lstAlertToVesselCompany = new List <AlertModel>(); OfferServices services = new OfferServices(); AlertTemplateServices templateServices = new AlertTemplateServices(); AlertServices alertServices = new AlertServices(); try { OfferModel val = new OfferModel(); if (offer.OfferId != null) { val = services.GetById((int)offer.OfferId); if (val == null) { throw new Exception("NOT_FOUND"); } } if (id.ToLower() == "offer") { offer.ProjectAdmin.PersonId = SessionWeb.User.PersonId; offer.UserModifiedId = SessionWeb.User.PersonId; result = services.InsComplete(offer); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("ID", offer.Vessel.VesselId.ToString()); AlertTemplateModel template = templateServices.GetById(8); AlertModel alert = alertServices.GetWithValues(template, values); lstAlertToProjectCompany.Add(alert); //Trick the form how i get the offer val = services.GetById((int)offer.OfferId); } else if (id.ToLower() == "accept") { offer.VesselAdmin.PersonId = SessionWeb.User.PersonId; offer.UserModifiedId = SessionWeb.User.PersonId; result = services.Accept(offer, (int)SessionWeb.User.PersonId); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("ID", "" + val.Project.ProjectId); AlertTemplateModel template = templateServices.GetById(10); AlertModel alert = alertServices.GetWithValues(template, values); lstAlertToProjectCompany.Add(alert); Dictionary <string, string> values2 = new Dictionary <string, string>(); values2.Add("ID", PersonSessionId.ToString()); AlertTemplateModel template2 = templateServices.GetById(11); AlertModel alert2 = alertServices.GetWithValues(template2, values2); lstAlertToVesselCompany.Add(alert2); } else if (id.ToLower() == "reject") { offer.VesselAdmin.PersonId = SessionWeb.User.PersonId; offer.UserModifiedId = SessionWeb.User.PersonId; result = services.Reject(offer); Dictionary <string, string> values2 = new Dictionary <string, string>(); values2.Add("ID", PersonSessionId.ToString()); AlertTemplateModel template2 = templateServices.GetById(11); AlertModel alert2 = alertServices.GetWithValues(template2, values2); lstAlertToVesselCompany.Add(alert2); } else if (id.ToLower() == "fix") { MessageServices chatServices = new MessageServices(); offer.VesselAdmin.PersonId = SessionWeb.User.PersonId; offer.UserModifiedId = SessionWeb.User.PersonId; if (val.Status == OfferModel.FIX && val.VesselAdmin.PersonId == SessionWeb.User.PersonId) { chatServices.MarkAsReaded( new MessageModel() { ReferenceId = offer.OfferId, From = SessionWeb.User.PersonId }); return(Json(result)); } if (val.Status == OfferModel.NEW) { result = services.Fix(offer); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("ID", offer.OfferId.ToString()); AlertTemplateModel template = templateServices.GetById(9); AlertModel alert = alertServices.GetWithValues(template, values); alert.To = val.ProjectAdmin.PersonId; result.Data.Add(alert); Dictionary <string, string> values2 = new Dictionary <string, string>(); values2.Add("ID", PersonSessionId.ToString()); AlertTemplateModel template2 = templateServices.GetById(11); AlertModel alert2 = alertServices.GetWithValues(template2, values2); lstAlertToVesselCompany.Add(alert2); } } if (result.Status == Status.Success) { var context = GlobalHost.ConnectionManager.GetHubContext <AlertHub>(); foreach (AlertModel alert in result.Data) { context.Clients.Group(string.Format("P{0}", alert.To)) .newAlert(alert); } foreach (AlertModel alert in lstAlertToProjectCompany) { context.Clients.Group(string.Format("C{0}", val.Project.CompanyId)) .newAlert(alert); } foreach (AlertModel alert in lstAlertToVesselCompany) { context.Clients.Group(string.Format("C{0}", val.Vessel.Company.CompanyId.ToString())) .newAlert(alert); } } } catch (Exception ex) { if (ex.Message == "STATUS_NOT_VALID") { result.Message = "La oferta ya no se encuentra disponible."; result.Status = Status.Error; } else if (ex.Message == "NOT_AVAILABILITY") { result.Message = "El barco seleccionado, no está disponible en las fechas seleccionadas."; result.Status = Status.Warning; } else { throw new Exception(result.Message); } } result.Data = null; return(Json(result)); }
public RequestResult <List <AlertModel> > Fix(OfferModel model) { RequestResult <List <AlertModel> > resp = new RequestResult <List <AlertModel> >(); MailServices MailServ = new MailServices(); ITemplate factory = new TemplateMessagesFactory(); VesselServices vesselServices = new VesselServices(); AlertServices alertServices = new AlertServices(); AlertTemplateServices templateServices = new AlertTemplateServices(); List <AlertModel> lstAlertToSend = new List <AlertModel>(); if (model.OfferId == null) { throw new Exception("REQUIRED OfferId"); } TransactionOptions scopeOptions = new TransactionOptions(); ////scopeOptions.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, scopeOptions)) { try { OfferModel val = GetById((int)model.OfferId); if (val == null) { throw new Exception("NOT_FOUND"); } if (val.Status != OfferModel.NEW) { throw new Exception("STATUS_NOT_VALID"); } OfferModel modelUpd = new OfferModel(); modelUpd.OfferId = model.OfferId; model.Status = OfferModel.FIX; InsUpd(model); Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("FLAG", val.Vessel.Country.Name); values.Add("HOMEPORT", val.Vessel.HomePort.Name); values.Add("IMO", val.Vessel.Imo); values.Add("VESSELNAME", val.Vessel.Name); values.Add("FOLIO", val.Project.Folio); //Notify to project owner alert and mail AlertModel alertFix = alertServices.GetWithValues(7, values); alertFix.To = val.ProjectAdmin.PersonId; lstAlertToSend.Add(alertFix); var respAlert = alertServices.InsUpd(alertFix); if (respAlert != null) { throw new Exception(respAlert.Message); } SystemVariableServices SVS = new SystemVariableServices(); Dictionary <string, string[]> param = new Dictionary <string, string[]>(); string EgulfUrl = SVS.GetSystemVariableValue("EgulfWeb"); param.Add("{Enfasis}", new string[] { val.Vessel.Country.Name, val.Vessel.HomePort.Name, val.Project.Folio }); param.Add("{Btn_url}", new string[] { EgulfUrl }); MailServ.SendMail(factory.GetTemplate(val.ProjectAdmin.Email, "OfferFix", param)); resp.Data = lstAlertToSend; ts.Complete(); } catch (Exception ex) { ts.Dispose(); resp = new RequestResult <List <AlertModel> >() { Status = Status.Error, Message = ex.Message }; Elmah.ErrorSignal.FromCurrentContext().Raise(ex); throw ex; } } return(resp); }
/// <summary> /// Method to go back to the precedent page /// Update the alerts in the same time /// </summary> /// <returns></returns> public async Task GoBack() { UpdateAlerts(); BoardWindow page = new BoardWindow(UserServices, AlertServices, MaterialServices, ProductServices, MaterialsProductServices, SaleServices, await AlertServices.CountAlerts()); page.Show(); CurrentPage.Close(); }
/// <summary> /// Method to go to the "Alert" page /// </summary> /// <returns></returns> private async Task GoToAlerts() { AlertsWindow page = new AlertsWindow(UserServices, AlertServices, MaterialServices, ProductServices, MaterialsProductServices, SaleServices, await AlertServices.GetAllAlerts()); page.Show(); CurrentPage.Close(); }
/// <summary> /// Creates a new window /// </summary> /// <param name="userServices"></param> /// <param name="alertServices"></param> /// <param name="countAlerts"></param> public BoardWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, int countAlerts) { InitializeComponent(); DataContext = new BoardViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, countAlerts); }
/// <summary> /// Creates a new window /// </summary> public StatisticsWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, Dictionary <string, int> countBySite, List <Tuple <string, int, int, int> > evolutionByMonth, float moneyEarned, Dictionary <int, float> moneyEarnedByYear) { InitializeComponent(); DataContext = new StatisticsViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, countBySite, evolutionByMonth, moneyEarned, moneyEarnedByYear); }
public CustomerController(AlertServices alertServices) { this.alertServices = alertServices; }
private async void OnDeleteContact(Contact selectedContact) { Contacts.Remove(selectedContact); await AlertServices.AlertAsync("Contacto borrado", "Contacto borrado exitosamente"); }