/// <summary> /// Adds the specified service level. /// </summary> /// <param name="serviceLevel">The service level.</param> /// <returns></returns> public tbl_ServiceLevel Add(tbl_ServiceLevel serviceLevel) { serviceLevel.ID = Guid.NewGuid(); _dataContext.tbl_ServiceLevel.AddObject(serviceLevel); _dataContext.SaveChanges(); return(serviceLevel); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { var accessCheck = Access.Check(TblUser, "Requests"); if (!accessCheck.Read) { Response.Redirect(UrlsData.LFP_AccessDenied(PortalSettingsId)); } Title = lrlTitle.Text = "Новый запрос"; ucContentComments.ContentId = ObjectId; gridRequirements.SiteID = SiteId; gridRequirements.Where.Add(new GridWhere() { CustomQuery = string.Format( "(tbl_Requirement.RequestID = '{0}' " + "OR tbl_Requirement.ID IN " + "(SELECT RequirementID FROM tbl_RequestToRequirement WHERE RequestID = '{0}'))", ObjectId.ToString()) }); if (ObjectId != Guid.Empty) { plViewRequest.Visible = true; } else { Contact = DataManager.Contact.SelectById(SiteId, (Guid)CurrentUser.Instance.ContactID); ServiceLevel = DataManager.ServiceLevel.SelectForContact(SiteId, Contact); if (ServiceLevel != null) { plAddRequest.Visible = true; hlCancel.NavigateUrl = UrlsData.LFP_Requests(PortalSettingsId); } else { ucNotificationMessage.Text = "Не определен уровень обслуживания."; } } gridRequirements.Actions.Add(new GridAction { Text = "Карточка требования", NavigateUrl = "~/" + PortalSettingsId + "/Main/Requirements/Edit/{0}", ImageUrl = "~/App_Themes/Default/images/icoView.png" }); if (!Page.IsPostBack) { BindData(); } }
/// <summary> /// Selects for contact. /// </summary> /// <param name="siteId">The site id.</param> /// <param name="contact">The contact.</param> /// <returns></returns> public tbl_ServiceLevel SelectForContact(Guid siteId, tbl_Contact contact) { var dataManager = new DataManager(); tbl_ServiceLevel serviceLevel = null; if (contact.CompanyID.HasValue) { serviceLevel = dataManager.ServiceLevel.SelectByCompanyId(siteId, (Guid)contact.CompanyID); } if (serviceLevel == null) { var serviceLevelContact = dataManager.ServiceLevelContact.SelectByContactId(contact.ID); if (serviceLevelContact != null) { serviceLevel = serviceLevelContact.tbl_ServiceLevelClient.tbl_ServiceLevel; } else { serviceLevel = dataManager.ServiceLevel.SelectDefault(siteId); if (serviceLevel == null) { return(null); } } } else { var serviceLevelClient = serviceLevel.tbl_ServiceLevelClient.FirstOrDefault(o => o.ClientID == contact.CompanyID); if (!dataManager.ServiceLevelContact.IsExistInClient(serviceLevelClient.ID, contact.ID)) { switch ((OutOfListServiceContacts)serviceLevelClient.OutOfListServiceContactsID) { case OutOfListServiceContacts.Reject: return(null); case OutOfListServiceContacts.Default: serviceLevel = dataManager.ServiceLevel.SelectDefault(siteId); break; } } } return(serviceLevel); }
/// <summary> /// Handles the OnClick event of the btnInsert control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnInsert_OnClick(object sender, EventArgs e) { var serviceLevel = new tbl_ServiceLevel { ID = Guid.NewGuid(), SiteID = CurrentUser.Instance.SiteID, Title = txtTitle.Text, ReactionTime = txtReactionTime.Value.HasValue ? (int)txtReactionTime.Value : 0, ResponseTime = txtResponseTime.Value.HasValue ? (int)txtResponseTime.Value : 0, IsActive = chxIsActive.Checked, IsDefault = chxIsDefault.Checked }; DataItem = serviceLevel; DataManager.ServiceLevel.Add(serviceLevel); }
/// <summary> /// Replaces the text. /// </summary> /// <param name="text">The text.</param> /// <param name="request">The request.</param> /// <param name="serviceLevel">The service level.</param> /// <param name="responsible">The responsible.</param> /// <param name="contact">The contact.</param> /// <param name="company">The company.</param> /// <returns></returns> protected string ReplaceText(string text, tbl_Request request, tbl_ServiceLevel serviceLevel, tbl_Contact responsible, tbl_Contact contact, tbl_Company company) { var shortDescription = request.ShortDescription; if (PortalSettings != null) { var requestLink = string.Format(RequestLinkTemplate, request.ID); shortDescription = string.Format("<a href='{0}'>{1}</a>", requestLink, shortDescription); } return(text.Replace("#Request.ShortDescription#", shortDescription) .Replace("#Request.CreatedAt#", request.CreatedAt.ToString("dd.MM.yyyy")) .Replace("#Request.ReactionTime#", serviceLevel.ReactionTime.ToString()) .Replace("#Request.Responsible.UserFullName#", responsible != null ? responsible.UserFullName : string.Empty) .Replace("#Request.ReactionDatePlanned#", request.ReactionDatePlanned.HasValue ? ((DateTime)request.ReactionDatePlanned).ToString("dd.MM.yyyy") : string.Empty) .Replace("#Request.Contact.UserFullName#", contact != null ? contact.UserFullName : string.Empty) .Replace("#Request.Company.Name#", company != null ? company.Name : string.Empty)); }
/// <summary> /// Selects the responsible id. /// </summary> /// <param name="requirementStatus">The requirement status.</param> /// <param name="serviceLevel">The service level.</param> /// <param name="companyId">The company id.</param> /// <returns></returns> public Guid SelectResponsibleId(tbl_RequirementStatus requirementStatus, tbl_ServiceLevel serviceLevel, Guid?companyId) { if (requirementStatus.ServiceLevelRoleID.HasValue) { var serviceLevelClient = serviceLevel.tbl_ServiceLevelClient.FirstOrDefault( o => o.ClientID == companyId); if (serviceLevelClient != null) { var serviceLevelContact = serviceLevelClient.tbl_ServiceLevelContact.FirstOrDefault( o => o.ServiceLevelRoleID == requirementStatus.ServiceLevelRoleID); if (serviceLevelContact != null) { return(serviceLevelContact.ContactID); } } } return(Guid.Empty); }
/// <summary> /// Updates the specified service level. /// </summary> /// <param name="serviceLevel">The service level.</param> public void Update(tbl_ServiceLevel serviceLevel) { _dataContext.SaveChanges(); }