protected void Page_Load(object sender, EventArgs e) { Per.CreatePrivilegeSession(); CreateCategoryLink.Visible = Per.Allowed("CreateCategory"); CreateCategoryLinkSeparator.Visible = Per.Allowed("CreateCategory"); CategoriesRpt.DataSource = DataBaseQueries.GetCategoriesInfoForCategoryList(); CategoriesRpt.DataBind(); //SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); //SqlCommand cmd = new SqlCommand(); //cmd.CommandType = CommandType.StoredProcedure; //cmd.CommandText = "GetCategoriesInfo"; //cmd.Connection = conn; //conn.Open(); //SqlDataReader reader = cmd.ExecuteReader(); //CategoriesRpt.DataSource = reader; //CategoriesRpt.DataBind(); //conn.Close(); }
public static void Compare(string nickname, Action action, int laps) { LogUtils.Log(nickname); var simpleDuration = TimeTrial.Attack(action, laps); var perFrame = Per.Frame( () => { try { action.Invoke(); return(true); } catch { return(false); } } ); // ReSharper disable once ReturnValueOfPureMethodIsNotUsed var perFrameDuration = TimeTrial.Attack(() => perFrame.Get(), laps); LogUtils.Log( new Dictionary <object, object>() { { nameof(simpleDuration), $"{nameof(simpleDuration.Average)}: {simpleDuration.Average.TotalMilliseconds}, {nameof(simpleDuration.Shortest)}: {simpleDuration.Shortest.TotalMilliseconds}, {nameof(simpleDuration.Longest)}: {simpleDuration.Longest.TotalMilliseconds}" }, { nameof(perFrameDuration), $"{nameof(perFrameDuration.Average)}: {perFrameDuration.Average.TotalMilliseconds}, {nameof(perFrameDuration.Shortest)}: {perFrameDuration.Shortest.TotalMilliseconds}, {nameof(perFrameDuration.Longest)}: {perFrameDuration.Longest.TotalMilliseconds}" }, { "Ratio", perFrameDuration.Average.Divide(simpleDuration.Average) } } ); }
public string Print() { return("Name: " + Pokemon + ", National Pokedex Number: " + Per.ToString() + ", Regional Pokedex Number: " + Nat + ", Base HP: " + HP.ToString() + ", Base Attack: " + Atk.ToString() + ", Base Defense: " + Def.ToString() + ", Base Sp.Attack: " + SpA.ToString() + ", Base Sp.Def: " + SpD.ToString() + ", Base Speed: " + Spe.ToString() + ", Total Base Stats: " + Total.ToString() + ", Type I: " + Type_I + ", Type II: " + Type_II + ", Tier: " + Tier + ", Ability I: " + Ability_I + ", Ability II: " + Ability_II + ", Hidden Ability: " + Hidden_Ability + ", Mass: " + Mass + ", Low Kick/Grass Knot damage: " + LK_GK.ToString() + ", EV Worth: " + EV_Worth + ", Exp Value: " + EXPV.ToString() + ", Pokedex Color: " + Color + ", Hatch: " + Hatch.ToString() + ", Gender" + Gender + ", Egg Group I: " + Egg_Group_I + ", Egg Group II: " + Egg_Group_II + ", Catch Rate: " + Catch.ToString() + ", Leveling Rate: " + LevelingRate()); }
public void Efficiency() { int iterations = 1; Func <double> func = () => Random.value; var sw = Stopwatch.StartNew(); sw.Start(); for (int i = 0; i < iterations; i++) { func.Invoke(); } sw.Stop(); var sw2 = Stopwatch.StartNew(); var perFrame = Per.Frame(func); sw2.Start(); for (int i = 0; i < iterations; i++) { var a = perFrame.Value; } sw2.Stop(); var swAvg = sw.Elapsed.TotalMilliseconds / iterations; var sw2Avg = sw2.Elapsed.TotalMilliseconds / iterations; LogUtils.Log($"sw: {sw.Elapsed}, avg: {swAvg}"); LogUtils.Log($"sw2: {sw2.Elapsed}, avg: {sw2Avg}"); LogUtils.Log($"cost: {sw2.Elapsed - sw.Elapsed}"); LogUtils.Log($"ratio: {sw2Avg / swAvg}"); }
public IEnumerator PerFameTest() { var firstFrame = Time.frameCount; var countedFunc = new CountedFunc <int>(() => Time.frameCount); var perFrame = Per.Frame(countedFunc.Invoke); Assert.That(perFrame.Peek(), Is.EqualTo(default(int)), $"Before any retrievals of {nameof(perFrame.Value)}, the value should be default"); for (int f = 0; f < 10; f++) { // LogUtils.Log($"frame: {f}, {Time.frameCount}"); Assert.That(countedFunc, Has.Property(nameof(countedFunc.InvocationCount)).EqualTo(f)); Assert.That(perFrame, Has.Property(nameof(perFrame.Freshness)).EqualTo(Freshness.Stale)); Assert.That(perFrame, Has.Property(nameof(perFrame.RefreshCount)).EqualTo(f)); for (int intraframe = 0; intraframe < 10; intraframe++) { // LogUtils.Log($"{nameof(frame)}: {frame}.{intraframe}"); Assert.That(perFrame, Has.Property(nameof(perFrame.Value)).EqualTo(f + firstFrame)); Assert.That(perFrame, Has.Property(nameof(perFrame.RefreshCount)).EqualTo(f + 1)); Assert.That(perFrame, Has.Property(nameof(perFrame.Freshness)).EqualTo(Freshness.Fresh)); Assert.That(countedFunc, Has.Property(nameof(countedFunc.InvocationCount)).EqualTo(f + 1)); } yield return(null); } }
public ActionResult AddPer(PerModel region, string acc, string TSHD, string TPD, string RVSBD, string TA) { if ((string)Session["Access"] != null) { Per p = new Per(); if ((string)Session["Access"] == "MainAdmin") { p.RegionName = region.RegionName; } else { p.RegionName = acc; } p.OD = region.OD; p.NMD = region.NMD; p.MBD = region.MBD; p.TSHD = TSHD; p.TPD = TPD; p.RVSBD = RVSBD; p.TA = TA; p.TF = region.TF; p.DG = region.DG; database.Pers.Add(p); database.SaveChanges(); return(RedirectToAction("Regions", "Admin")); } else { Session["Save"] = "False"; return(Content("ثبت نشد")); } }
static void Main(string[] args) { string a; Console.WriteLine("ingrese los datos se su personaje"); Per personaje1 = new Per(); personaje1 = personaje1.CrearPj(personaje1); personaje1.Mostrar(); Per personaje2 = new Per(); personaje2 = personaje2.CrearPj(personaje2); personaje2.Mostrar(); do { Console.WriteLine("¿esta listo para una pelea? (s/n)"); a = Console.ReadLine(); }while (a != "s"); Console.Clear(); for (int i = 1; i < 4; i++) { Console.WriteLine("\nTurno numero " + i); personaje1 = turno(personaje2, personaje1); personaje2 = turno(personaje1, personaje2); Console.WriteLine("\n"); } ganador(personaje2, personaje1); }
protected void Page_Load(object sender, EventArgs e) { PostEditor.Visible = Per.Allowed("CreatePost"); PostEditorDivider.Visible = Per.Allowed("CreatePost"); ShowEditor.Visible = !Per.Allowed("CreatePost"); Session["LastPage"] = Request.Url.PathAndQuery; CatId = Convert.ToString(Session["CatId"]); CatName = Convert.ToString(Session["CatName"]); //Hvis bruger er logget ind skal ShpwEditor-knappen fjernes, og editoren skal vises. //PostCounter(); QsId = Request.QueryString["Id"]; Session["ThreadId"] = QsId; PostsRpt.DataSource = DataBaseQueries.GetThreadContent(QsId); PostsRpt.DataBind(); TitleRpt.DataSource = DataBaseQueries.GetThreadTitle(QsId); TitleRpt.DataBind(); TitleRpt2.DataSource = DataBaseQueries.GetThreadTitle(QsId); TitleRpt2.DataBind(); //foreach (RepeaterItem item in PostsRpt.Items) //{ // FindControl("EditPostLink").Visible = false; //} }
public IActionResult Delete(Per per) { var result = _perService.Delete(per); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public static bool ThreadOwnerPrivilege(object ThreadId) { if (ThreadId.ToString() != "") { int NewThreadId = Convert.ToInt32(ThreadId); return((Per.IsThreadMine("EditThread", NewThreadId) || Per.IsThreadMine("IsThreadOwner", NewThreadId)) ? true : false); } else { return(false); } }
public void ForcedRefreshTest() { var countedFunc = new CountedFunc <int>(() => Time.frameCount); var perFrame = Per.Frame(countedFunc.Invoke); for (int intraframe = 0; intraframe < 10; intraframe++) { Assert.That(countedFunc, Has.Property(nameof(countedFunc.InvocationCount)).EqualTo(intraframe)); Validations.ForcedRefresh(perFrame); Assert.That(countedFunc, Has.Property(nameof(countedFunc.InvocationCount)).EqualTo(intraframe + 1)); } }
public static PatientEntity toPatientEntity(this Per per) { return(new PatientEntity() { Id = per.PerOwnId, Bday = per.PerBir, FiscalCode = per.PerFCd, Name = per.PerNam, Surname = per.PerSur, Sex = per.PerSex }); }
/// <summary> /// refresh view /// </summary> public void RefreshView() { ClearPanel(); ArrayList thePersonList = myModel.PersonList; Person[] thePersons = (Person[])thePersonList.ToArray(typeof(Person)); Graphics g = this.Canvas.CreateGraphics(); foreach (Person Per in thePersons) { Per.ShowPerson(g); } }
public static void ganador(Per pj1, Per pj2) { if (pj1.Salud > pj2.Salud) { Console.WriteLine("El ganador es: " + pj1.Nombre); } else if (pj1.Salud == pj2.Salud) { Console.WriteLine("Ambos jugadores empataron"); } else { Console.WriteLine("El ganador es: " + pj2.Nombre); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserId"] == null) { if (Session["RoleId"] == null) { //RoleId 3 is guest-role Session["RoleId"] = 3; } } Per.CreatePrivilegeSession(); LoginLink.Visible = Per.Allowed("Login"); CreateUserLink.Visible = Per.Allowed("CreateUser"); MyPageLink.Visible = Per.Allowed("MyPage"); UserListLink.Visible = Per.Allowed("ShowUserList"); UserListLinkDivider.Visible = Per.Allowed("ShowUserList"); LogOutLink.Visible = Per.Allowed("LogOut"); LogOutLinkDivider.Visible = Per.Allowed("LogOut"); //________________________________________// if (Session["FlashMsgSuccess"] != null) { // Vis besked PanelMsg.Visible = true; PanelMsg.CssClass = "alert alert-success alert-dismissable"; LabelMsg.Text = Session["FlashMsgSuccess"].ToString(); // Fjern beskeder fra Session Session["FlashMsgSuccess"] = null; Session["FlashMsgDanger"] = null; } if (Session["FlashMsgDanger"] != null) { // Vis besked PanelMsg.Visible = true; PanelMsg.CssClass = "alert alert-danger alert-dismissable"; LabelMsg.Text = Session["FlashMsgDanger"].ToString(); // Fjern beskeder fra Session Session["FlashMsgDanger"] = null; Session["FlashMsgSuccess"] = null; } //_________________________________________// }
/// <summary> /// Display graphics through filtering takes two arguments /// </summary> /// <param name="text"></param> /// <param name="text1"></param> public void DisplayPersons(string text, string text1) { ClearPanel(); ArrayList thePersonList = myModel.PersonList; Person[] thePersons = (Person[])thePersonList.ToArray(typeof(Person)); Graphics g = this.Canvas.CreateGraphics(); foreach (Person Per in thePersons) { if (Per.getPersonType.Equals(text) || Per.getPersonType.Equals(text1)) { Per.ShowPerson(g); } } }
public static Per ToPer(this PatientEntity patient, Per per = null) { if (per == null) { per = new Per(); } per.PerOwnId = patient.Id; per.PerBir = patient.Bday; per.PerFCd = patient.FiscalCode; per.PerNam = patient.Name; per.PerSur = patient.Surname; per.PerSex = patient.Sex; return(per); }
protected void Page_Load(object sender, EventArgs e) { if (!Per.Allowed("ShowUserList")) { Response.Redirect("Default.aspx"); } else { Session["LastPage"] = Request.Url.PathAndQuery; if (!IsPostBack) { UserListRpt.DataSource = DataBaseQueries.GetUserListInfo(); UserListRpt.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { LastPage = Convert.ToString(Session["LastPage"]).Trim(); UserName = Convert.ToString(Session["UserName"]); PassWord = Convert.ToString(Session["PassWord"]); string RoleId; //Authenticate if (DataBaseQueries.AuthenticateUserCredentials(UserName, PassWord)) { //Build Session: //UserId, RoleId RoleId = Convert.ToString(Session["RoleId"]); //Get privileges Per.CreatePrivilegeSession(); //Return to last page or frontpage?___// if (LastPage != null && LastPage != "") { //Back to the last page Response.Redirect(LastPage); } else { //Til Forsiden Response.Redirect("Default.aspx"); } //____________________________________// } else { //sæt brugerens rolle til gæst RoleId = "3"; //Get privileges Per.CreatePrivilegeSession(); //Fejl. Brugeren findes ikke Session["FlashMsgDanger"] = "Fejl i brugernavn eller password"; //Tilbage til Login-siden Response.Redirect("Login.aspx"); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; // Suitable nullity checks etc, of course :) if (Date != null) { hashCode = hashCode * 59 + Date.GetHashCode(); } if (Rehabilitation != null) { hashCode = hashCode * 59 + Rehabilitation.GetHashCode(); } if (TurnoverRate != null) { hashCode = hashCode * 59 + TurnoverRate.GetHashCode(); } if (Per != null) { hashCode = hashCode * 59 + Per.GetHashCode(); } if (Psr != null) { hashCode = hashCode * 59 + Psr.GetHashCode(); } if (Pcfr != null) { hashCode = hashCode * 59 + Pcfr.GetHashCode(); } if (Pbr != null) { hashCode = hashCode * 59 + Pbr.GetHashCode(); } if (Stopped != null) { hashCode = hashCode * 59 + Stopped.GetHashCode(); } if (SpecialTreatment != null) { hashCode = hashCode * 59 + SpecialTreatment.GetHashCode(); } return(hashCode); } }
/// <inheritdoc/> protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken)) { if (Owner != null && Name != null && Per != null) { var ownerValue = Owner.GetValue(dc.State); var nameValue = Name.GetValue(dc.State); var perValue = Per.GetValue(dc.State); return(await gitHubClient.Repository.Traffic.GetClones(ownerValue, nameValue, perValue).ConfigureAwait(false)); } if (RepositoryId != null && Per != null) { var repositoryIdValue = RepositoryId.GetValue(dc.State); var perValue = Per.GetValue(dc.State); return(await gitHubClient.Repository.Traffic.GetClones((Int64)repositoryIdValue, perValue).ConfigureAwait(false)); } throw new ArgumentNullException("Required [per] arguments missing for GitHubClient.Repository.Traffic.GetClones"); }
public static Per turno(Per pjAtac, Per pjDef) { Random efectividad = new Random(); int PD = pjAtac.Fuerza * pjAtac.Destreza * pjAtac.Nivel; int ED = efectividad.Next(1, 100); int VA = PD * ED; int PDEF = pjAtac.Armadura * pjAtac.Velocidad; int dañoProb = (VA - PDEF) / 500; Console.WriteLine("el jugador " + pjAtac.Nombre + "ha atacado"); Console.WriteLine("daño probocado= " + dañoProb); pjDef.Salud = pjDef.Salud - dañoProb; Console.WriteLine("salud actual de " + pjDef.Nombre + " es: " + pjDef.Salud); return(pjDef); }
private void actualiserListePersonnelOngletPersonnel() { listePersonnel.Items.Clear(); foreach (Personnel Per in lesPersonnels) { listePersonnel.Items.Add(Per.infos()); } foreach (Visiteur Vis in lesVisiteurs) { listePersonnel.Items.Add(Vis.infos()); } foreach (Technicien Tec in lesTechniciens) { listePersonnel.Items.Add(Tec.infos()); } }
public int Delete(PatientEntity patient) { try { using (var db = new CroceRossaEntities()) { Per per = db.Per.First(x => x.PerOwnId == patient.Id); if (per != null) { db.Per.Remove(per); db.SaveChanges(); } return(0); } } catch (Exception) { return(-1); } }
protected void Page_Load(object sender, EventArgs e) { CreateThreadLink.Visible = Per.Allowed("CreateThread"); Session["LastPage"] = Request.Url.PathAndQuery; QsModel = "Category"; QsId = Request.QueryString["Id"]; Session["CatId"] = QsId; CatName = Convert.ToString(DataBaseQueries.GetModelTitle(QsModel, QsId)); Session["CatName"] = CatName; Session["CatId"] = QsId; ThreadRpt.DataSource = DataBaseQueries.GetThreadInfoData(QsId); ThreadRpt.DataBind(); }
private void EqualsBottn_Click(object sender, EventArgs e) { second = double.Parse(TxtScreen.Text); double Add; double Sub; double Mul; double Div; double Per; switch (operador) { case "+": Add = obj.Add((first), (second)); TxtScreen.Text = Add.ToString(); break; case "-": Sub = obj2.Substraction((first), (second)); TxtScreen.Text = Sub.ToString(); break; case "x": Mul = obj3.Multiply((first), (second)); TxtScreen.Text = Mul.ToString(); break; case "/": Div = obj4.Divide((first), (second)); TxtScreen.Text = Div.ToString(); break; case "%": Per = obj5.Percentage((first), (second)); TxtScreen.Text = Per.ToString(); break; } }
private void btn_Register_AssignChip_Click(object sender, EventArgs e) { listBox_AssignChip.Items.Clear(); try { if (tb_TicketID_AssignChip.Text != "" && tb_FirstName_AssignChip.Text != "" && tb_LastName_AssignChip.Text != "" && tb_Email_AssignChip.Text != "" && comboBox_Day_AssignChip.Text != "" && comboBox_Month_AssignChip.Text != "" && comboBox_Year_AssignChip.Text != "") { int day = Convert.ToInt32(comboBox_Day_AssignChip.SelectedItem); int month = Convert.ToInt32((comboBox_Month_AssignChip.SelectedIndex + 1)); int year = Convert.ToInt32(comboBox_Year_AssignChip.SelectedItem); int TicketID = Convert.ToInt32(tb_TicketID_AssignChip.Text); string FirstName = tb_FirstName_AssignChip.Text; string LastName = tb_LastName_AssignChip.Text; DateTime dob = new DateTime(year, month, day); string Email = tb_Email_AssignChip.Text; DateTime dt = DateTime.Now; bool found = false; string braceletid = ""; Person P = null; foreach (Person PR in persons) { if (PR.TicketID == TicketID) { found = true; } } if (found == false) { P = new Person(TicketID, FirstName, LastName, dob, Email, dt); if (dh.AddAPersontoDB(P)) { persons.Add(P); if (ShowInputDialog(ref braceletid) == DialogResult.OK) { if (dh.InsertBraceletID(braceletid) == true) { P.SetBraceletID(braceletid); P.SetCheckInDateTime(DateAndTime.Now); dh.SetBraceletIDForPerson(P, braceletid); dh.SetCheckInForDB(P); tbEntranceApp = null; tb_TicketID_AssignChip.Text = dh.GetLastIDfromDB().ToString(); } else { MessageBox.Show("Bracelet registration failed!"); } } else { tbEntranceApp = null; } foreach (string s in P.ListOfString()) { listBox_AssignChip.Items.Add(s); } } } else if (found == true) { foreach (Person Per in persons) { if (Per.TicketID == TicketID) { if (ShowInputDialog(ref braceletid) == DialogResult.OK) { if (dh.InsertBraceletID(braceletid)) { dh.SetBraceletIDForPerson(Per, braceletid); dh.SetCheckInForDB(Per); Per.SetBraceletID(braceletid); Per.SetCheckInDateTime(DateAndTime.Now); } else { MessageBox.Show("Bracelet registration failed!"); } } foreach (string s in Per.ListOfString()) { listBox_AssignChip.Items.Add(s); } } } } } else { MessageBox.Show("Please fill all fields!"); } } catch (FormatException) { MessageBox.Show("Please, complete all information correctly!"); } catch (Exception) { MessageBox.Show("Something went wrong!"); } tb_FirstName_AssignChip.Clear(); tb_LastName_AssignChip.Clear(); tb_Email_AssignChip.Clear(); comboBox_Day_AssignChip.Text = ""; comboBox_Month_AssignChip.Text = ""; comboBox_Year_AssignChip.Text = ""; tb_TicketID_AssignChip.Text = dh.GetLastIDfromDB().ToString(); }
/// <summary> /// 获取个人信息 get请求 /// </summary> /// <returns></returns> public ActionResult GetPerInfo() { string jsonTxt = ""; HttpCookie loginUserCookie = Request.Cookies["loginUserInfo"]; if (loginUserCookie != null) { int userId = Convert.ToInt32(loginUserCookie.Values["loginUserId"]); var per = PersonalinformationService.LoadEntities(p => p.iUserID == userId).FirstOrDefault(); var user = UserService.LoadEntities(u => u.ID == userId).FirstOrDefault(); if (per != null && user != null) { Per perInfo = new Per(); if (!String.IsNullOrEmpty(user.vcNickName)) { perInfo.nickName = user.vcNickName; } if (!String.IsNullOrEmpty(per.vcName)) { perInfo.name = per.vcName; } if (!String.IsNullOrEmpty(user.vcProfilePhotoAddress)) { perInfo.perLogo = user.vcProfilePhotoAddress; } if (!String.IsNullOrEmpty(per.vcGender)) { perInfo.gender = per.vcGender; } if (!String.IsNullOrEmpty(per.vcGrade)) { perInfo.grade = per.vcGrade; } if (!String.IsNullOrEmpty(per.vcMajor)) { perInfo.major = per.vcMajor; } if (per.dBirthday != null) { perInfo.birthday = (DateTime)per.dBirthday; } if (!String.IsNullOrEmpty(per.cPhone)) { perInfo.phone = per.cPhone; } if (!String.IsNullOrEmpty(per.vcWeChat)) { perInfo.wechat = per.vcWeChat; } if (!String.IsNullOrEmpty(per.vcQQ)) { perInfo.QQ = per.vcQQ; } if (!String.IsNullOrEmpty(per.vcEmail)) { perInfo.Email = per.vcEmail; } if (!String.IsNullOrEmpty(per.vcHobby)) { perInfo.hobby = per.vcHobby; } if (!String.IsNullOrEmpty(per.vcAddress)) { perInfo.address = per.vcAddress; } if (!String.IsNullOrEmpty(per.vcPersonalIntroduce)) { perInfo.introduce = per.vcPersonalIntroduce; } var timerConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd" }; jsonTxt = JsonConvert.SerializeObject(perInfo, Newtonsoft.Json.Formatting.Indented); } else //未找到数据 { status = "no"; result = "未找到数据"; jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}"; } } else //未登录 { status = "no"; result = "未登录"; jsonTxt = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "result" + "\"" + ":" + "\"" + result + "\"" + "}"; } return(Content(jsonTxt)); }
/// <summary> /// Returns true if DailyPrice instances are equal /// </summary> /// <param name="other">Instance of DailyPrice to be compared</param> /// <returns>Boolean</returns> public bool Equals(DailyPrice other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (Equals((PriceBase)other) && ( Date == other.Date || Date != null && Date.Equals(other.Date) ) && ( PreClosing == other.PreClosing || PreClosing != null && PreClosing.Equals(other.PreClosing) ) && ( Rehabilitation == other.Rehabilitation || Rehabilitation != null && Rehabilitation.Equals(other.Rehabilitation) ) && ( TurnoverRate == other.TurnoverRate || TurnoverRate != null && TurnoverRate.Equals(other.TurnoverRate) ) && ( Per == other.Per || Per != null && Per.Equals(other.Per) ) && ( Psr == other.Psr || Psr != null && Psr.Equals(other.Psr) ) && ( Pcfr == other.Pcfr || Pcfr != null && Pcfr.Equals(other.Pcfr) ) && ( Pbr == other.Pbr || Pbr != null && Pbr.Equals(other.Pbr) ) && ( Stopped == other.Stopped || Stopped != null && Stopped.Equals(other.Stopped) ) && ( SpecialTreatment == other.SpecialTreatment || SpecialTreatment != null && SpecialTreatment.Equals(other.SpecialTreatment) )); }
public HttpResponseMessage Signup(SignupRequestInfo signupRequestInfo) { OrgCust newCustomer = new OrgCust(); OrgReseller newReseller = new OrgReseller(); try { var rolename = 0; bool isNewCustomer = signupRequestInfo.userType == "RESE" ? false : true; var orgCustomerType = _IOrgtypService.GetOrgtyps().Where(p => p.TypCd == SystemConstants.ORG_TYPE_CD_CUSTOMER).FirstOrDefault(); var orgResellerType = _IOrgtypService.GetOrgtyps().Where(p => p.TypCd == SystemConstants.ORG_TYPE_CD_RESELLER).FirstOrDefault(); var newOrg = _IOrgService.GetOrgs().Where(p => p.soKey == Guid.Parse(signupRequestInfo.id)).FirstOrDefault(); if (newOrg == null) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid Invitation")); } Locn newLocn = new Locn { AddressLine1 = signupRequestInfo.addressStreet1, AddressLine2 = signupRequestInfo.addressStreet2, City = signupRequestInfo.addressCity, DateLastMaint = DateTime.UtcNow, CreateDate = DateTime.UtcNow, State = signupRequestInfo.addressState, ZipCode = signupRequestInfo.addressZip }; var os = _IOrgtyporgstatusService.GetOrgtyporgstatus().Where(p => p.OrgStatus.StatusCd == "INREVIEW").FirstOrDefault(); newOrg.OrgStatusHists.Add(new OrgStatusHist() { Org = newOrg, OrgTypOrgStatu = os, CreateDate = DateTime.UtcNow }); // Associate Organization to Location newOrg.OrgLocns.Add(new OrgLocn { Locn = newLocn, Org = newOrg }); // Created New OrgCust or OrgReseller based on request if (isNewCustomer) { rolename = 2; } else { rolename = 3; } _IOrgService.UpdateOrg(newOrg); // Create User var newuser = _IUserService.GetUsers().Where(p => p.UserName == signupRequestInfo.email).FirstOrDefault(); var ctype = _IContacttypService.GetContacttyps().Find(p => p.ContactTypCd == "PHON"); var contact = new Contact { ContactTyp = ctype, Value = signupRequestInfo.phone }; var curDateTime = DateTime.UtcNow; var guid = Guid.NewGuid(); if (newuser.Per == null) { Per per = new Per() { FirstName = signupRequestInfo.firstName, LastName = signupRequestInfo.lastName, MiddleName = signupRequestInfo.middleName, Createdate = curDateTime, Title = signupRequestInfo.contactTitle }; newuser.Per = per; } else { newuser.Per.FirstName = signupRequestInfo.firstName; newuser.Per.MiddleName = signupRequestInfo.middleName; newuser.Per.LastName = signupRequestInfo.lastName; newuser.Per.Title = signupRequestInfo.contactTitle; } newuser.Per.PersContacts.Add(new PersContact() { Per = newuser.Per, Contact = contact }); var authrole = _IAuthrolService.GetAuthrol(rolename); newuser.UserAuthRols.Add(new UserAuthRol() { User = newuser, AuthRol = authrole }); newuser.InactiveDate = null; newuser.InviteDate = null; var messagetemp = _IMessagetemplateService.GetMessagetemplates().Where(p => p.Name == "SignupAccepted").FirstOrDefault(); var baseUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority); if (messagetemp != null) { newuser.MessageUsers.Add(new MessageUser() { User = newuser, DeliveryMethodId = 1, Message = new Message() { CreateDate = curDateTime, HeaderText = messagetemp.HeaderText, MessageBody = messagetemp.TemplateText + "\n" + baseUrl + "/login" } }); } _IUserService.UpdateUser(newuser); _IUserService.UpdatePassword(signupRequestInfo.email, PasswordHash.CreateHash(signupRequestInfo.password)); // Create Sign Up Workflow WkflowDef signUpWorkflow; int wkflowDefId = isNewCustomer ? 1 : 2; // 1= customer signup , 2 = reseller signup signUpWorkflow = _IWkflowdefService.GetWkflowdefs().Where(p => p.Id == wkflowDefId).FirstOrDefault(); var signUpWorkflowInstance = new WkflowInstance { CreateDate = DateTime.UtcNow, DateLastMaint = DateTime.UtcNow, WkflowDefId = signUpWorkflow.Id, OrgId = newOrg.Id, UserId = 1, CurrWkflowStatId = 5//InReview State }; signUpWorkflowInstance.WkflowStepHists.Add(new WkflowStepHist { CreateDate = DateTime.UtcNow, DateLastMaint = DateTime.UtcNow, WkflowStatId = 5, CreatedUserId = 1 }); _IWkflowinstanceService.AddWkflowinstance(signUpWorkflowInstance); return(Request.CreateResponse <bool>(HttpStatusCode.OK, true)); } catch (Exception daExp) { return(Request.CreateResponse <bool>(HttpStatusCode.InternalServerError, false)); } }