public CellPhone GetById(int Id) { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ViaConnection"].ConnectionString)) { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText = "dbo.iPhone_SelectById"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", Id); CellPhone newCell = new CellPhone(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { var position = 0; CellPhone result = new CellPhone(); result.Id = reader.GetInt32(position++); result.Model = reader.GetString(position++); result.Price = reader.GetInt32(position++); newCell = result; } } return(newCell); } }
public Product get_product() { CellPhone cp = this.cellphone; this.reset(); return(cp); }
private void RemoveNonNumericFromCellPhone() { if (CellPhone != null) { CellPhone = CellPhone.RemoveNonNumeric().RemoveWhitespace(); } }
public HttpResponseMessage GetById(int Id) { CellPhone response = new CellPhone(); response = _svc.GetById(Id); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
static void Main(string[] args) { // client code ElectornicsManufacture em = new ElectornicsManufacture(); // builds phones CellPhoneBuilder builder = new CellPhoneBuilder(); em.set_builder(builder); em.build_iphone(); CellPhone iPhone = (CellPhone)em.get_product(); iPhone.use_phone(); em.build_samsung_note(); CellPhone note = (CellPhone)em.get_product(); note.use_phone(); // builds laptops LaptopBuilder builder2 = new LaptopBuilder(); em.set_builder(builder2); em.build_thinkpad(); Laptop tp = (Laptop)em.get_product(); tp.use_laptop(); }
public ActionResult AddReview(CellPhoneAdViewModel cellPhoneAdViewModel, int?id, string Review) { if (Review.Length >= 50) { CellPhone cellPhone = CellPhones.GetByID(id); if (cellPhone == null) { return(HttpNotFound()); } string CurrentUserName = User.Identity.GetUserName(); Review newReview = new Review(); newReview.Content = Review; newReview.AdID = cellPhone.AdID; newReview.Ad = cellPhone.Ad; newReview.PostingTime = DateTime.Now; Seller seller = Sellers.GetAll().Where(s => s.Username == CurrentUserName).FirstOrDefault(); newReview.SellerID = seller.ID; newReview.Seller = seller; newReview.ReviewStars = 5; Reviews.Insert(newReview); Reviews.Commit(); return(RedirectToAction("Details", "CellPhoneAds", new { id = id })); } return(RedirectToAction("Details", "CellPhoneAds", new { id = id })); }
public void AcceptIncomingCall(string inputNumber, CellPhone phone) { Contact contact = phone.SimCard.GetContactByNumber(inputNumber); Console.WriteLine(contact != null ? contact.Name : "Неизвестный абонент"); phone.Ring(inputNumber); }
public void CallAnotherUser(string contactNameOrNumber, CellPhone phone) { Contact contact = phone.SimCard.GetContactByName(contactNameOrNumber); string outputNumber = contact != null?contact.Numbers.First() : contactNameOrNumber; phone.Call(outputNumber); }
public async Task <IActionResult> Edit(int id, [Bind("CellPhoneId,CellPhoneName,ShortDescription,LongDescription,Image,Price,InStock")] CellPhone cellPhone) { if (id != cellPhone.CellPhoneId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cellPhone); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(cellPhone.CellPhoneId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cellPhone)); }
static void Main(string[] args) { CellPhone phone = new CellPhone(); string[] numbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); foreach (var number in numbers) { if (phone.AddPhone(number)) { phone.Calling(number); } else { Console.WriteLine("Invalid number!"); } } string[] web = Console.ReadLine().Split(); foreach (var site in web) { if (phone.AddWebSite(site)) { phone.Browsing(site); } else { Console.WriteLine("Invalid URL!"); } } }
public void FormattedShouldReturnEmptyWhenInvalid() { var phone = new CellPhone("3198542392"); var formattedNumber = phone.Formatted(); Assert.IsTrue(string.IsNullOrEmpty(formattedNumber)); }
public ActionResult Create(CellPhone product) { Db.CellPhones.Add(product); Db.SaveChangesAsync(); return(RedirectToAction("Index", "Product", null)); }
public void TouchesEnded( ) { FirstName.ResignFirstResponder( ); LastName.ResignFirstResponder( ); SpouseName.ResignFirstResponder( ); Email.ResignFirstResponder( ); CellPhone.ResignFirstResponder( ); }
private new void Awake() { base.Awake(); interact = WatchTV; stopInteract = WatchTV; cellPhone = GameObject.FindObjectOfType <CellPhone>(); }
public ActionResult DeleteConfirmed(int id) { CellPhone cellPhone = CellPhones.GetByID(id); CellPhones.Delete(cellPhone); CellPhones.Commit(); return(RedirectToAction("Index")); }
public bool UpdateCellPhone(CellPhone cellobj) { try { CellPhone oldCell = (from cell in DataContext.CellPhones where cell.ProductID == cellobj.ProductID select cell).First(); oldCell.ProductID = cellobj.ProductID; oldCell.ProductName = cellobj.ProductName; oldCell.Price = cellobj.Price; oldCell.BrandName = cellobj.BrandName; oldCell.Photo = cellobj.Photo; oldCell.CategoryID = cellobj.CategoryID; oldCell.SubCategoryID = cellobj.SubCategoryID; oldCell.Display = cellobj.Display; oldCell.OperatingSystem = cellobj.OperatingSystem; oldCell.Processor = cellobj.Processor; oldCell.TouchScreen = cellobj.TouchScreen; oldCell.ScreenSize = cellobj.ScreenSize; oldCell.StandByTime = cellobj.StandByTime; int result = DataContext.SaveChanges(); } catch (DbUpdateException ex) { dc.PCErrorLoggers.Add(new PCErrorLogger() { ErrorDate = DateTime.Now, ErrorMessage = ex.Message, ErrorSource = ex.Source }); dc.SaveChanges(); throw new DbUpdateException("Please enter valid Foreign keys"); } catch (System.FormatException fe) { dc.PCErrorLoggers.Add(new PCErrorLogger() { ErrorDate = DateTime.Now, ErrorMessage = fe.Message, ErrorSource = fe.Source }); dc.SaveChanges(); throw new System.FormatException(); } catch (Exception q) { dc.PCErrorLoggers.Add(new PCErrorLogger() { ErrorDate = DateTime.Now, ErrorMessage = q.Message, ErrorSource = q.Source }); dc.SaveChanges(); throw new Exception("Incorrect Format"); } return(true); }
public Customer Put([FromBody] CreateCustomerCommand customerCommand) { var name = new Name(customerCommand.FirstName, customerCommand.LastName); var document = new Document(customerCommand.Document); var email = new Email(customerCommand.Email); var phone = new CellPhone(customerCommand.Phone); var customer = new Customer(name, document, email, phone); return(customer); }
public ICommandResult Handle(CreateCustomerCommand command) { //To do // Verficar se o CPF já existe no BD if (this._repository.CheckDocument(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); } // Verificar se o E-mail já existe na base if (this._repository.CheckEmail(command.Email)) { AddNotification("Email", "Este E-mail já está em uso"); } // Criar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document); var email = new Email(command.Email); var phone = new CellPhone(command.Phone); // Criar a entidade var customer = new Customer(name, document, email, phone); // Validar entidades e VOs AddNotifications(name.Notifications); AddNotifications(document.Notifications); AddNotifications(email.Notifications); AddNotifications(phone.Notifications); AddNotifications(customer.Notifications); if (Invalid) { return(new CommandResult( false, "Por favor, corrija os campos abaixo", Notifications)); } // Persistir o cliente this._repository.Save(customer); // Enviar um E-mail de boas vindas this._emailService.Send(customer.Email.Address, "*****@*****.**", "Seja Bem-vindo", "Seja bem-vindo a Teste Store =D"); AddNotifications(customer.Notifications); // Retornar o resultado para tela return(new CommandResult(true, "Bem vindo ao Testo Store", new { customer.Id, Name = customer.Name.ToString(), Email = customer.Email.Address })); }
public void AddCellPhone(CellPhone cellPhone) { if (cellPhone.Valid) { CellPhone = cellPhone; } else { AddNotifications(cellPhone); } }
public async Task <IActionResult> Create([Bind("CellPhoneId,CellPhoneName,ShortDescription,LongDescription,Image,Price,InStock,CategoryId")] CellPhone cellPhone) { if (ModelState.IsValid) { _context.Add(cellPhone); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cellPhone)); }
public virtual void Validate(ValidationResult result) { HireDate.ValidateRequired(result, nameof(HireDate)); Name.ValidateRequired(result, nameof(Name)); Name.ValidateMaxLength(result, nameof(Name), 50); CellPhone?.Validate(result); Spouse?.Validate(result); }
public Customer( Name name, Document document, Email email, CellPhone phone) { this.Name = name; this.Document = document; this.Email = email; this.Phone = phone; this._addresses = new List <Address>(); }
public IActionResult Update(string id, CellPhone cellPhoneIn) { var cellPhone = _cellPhoneService.Get(id); if (cellPhone == null) { return(NotFound()); } _cellPhoneService.Update(id, cellPhoneIn); return(NoContent()); }
public void Run() { var inputNumbers = Reader.ReadLine().Split(); var inputSites = Reader.ReadLine().Split(); ICall call = new CellPhone(); Writer.WriteLine(call.Call(inputNumbers)); IBrowse browse = new CellPhone(); Writer.WriteLine(browse.Browse(inputSites)); }
public override void Validate(ValidationResult result) { base.Validate(result); HireDate.ValidateRequired(result, nameof(HireDate)); CellPhone.Validate(result); foreach (var person in Dependants) { person.Validate(result); } }
public override void ViewDidLayoutSubviews() { base.ViewDidLayoutSubviews(); BlockerView.SetBounds(View.Bounds.ToRectF( )); ResultView.SetBounds(View.Bounds.ToRectF( )); HeaderView.Frame = new CGRect(View.Frame.Left, View.Frame.Top, View.Frame.Width, StyledTextField.StyledFieldHeight); ScrollView.Frame = new CGRect(View.Frame.Left, HeaderView.Frame.Bottom, View.Frame.Width, View.Frame.Height - HeaderView.Frame.Height); NickName.SetFrame(new CGRect(-10, View.Frame.Height * .05f, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); LastName.SetFrame(new CGRect(-10, NickName.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); Email.SetFrame(new CGRect(-10, LastName.Background.Frame.Bottom + 20, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); CellPhone.SetFrame(new CGRect(-10, Email.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); Street.SetFrame(new CGRect(-10, CellPhone.Background.Frame.Bottom + 20, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); City.SetFrame(new CGRect(-10, Street.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); State.SetFrame(new CGRect(-10, City.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); Zip.SetFrame(new CGRect(-10, State.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); Gender.SetFrame(new CGRect(-10, Zip.Background.Frame.Bottom + 20, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); GenderButton.Frame = Gender.Background.Frame; Birthdate.SetFrame(new CGRect(-10, Gender.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); BirthdayButton.Frame = Birthdate.Background.Frame; HomeCampus.SetFrame(new CGRect(-10, Birthdate.Background.Frame.Bottom, View.Frame.Width + 20, StyledTextField.StyledFieldHeight)); HomeCampusButton.Frame = HomeCampus.Background.Frame; DoneButton.Frame = new CGRect(View.Frame.Left + 10, HomeCampus.Background.Frame.Bottom + 20, View.Bounds.Width - 20, ControlStyling.ButtonHeight); LogoutButton.Frame = new CGRect((View.Frame.Width - ControlStyling.ButtonWidth) / 2, DoneButton.Frame.Bottom + 20, ControlStyling.ButtonWidth, ControlStyling.ButtonHeight); nfloat controlBottom = LogoutButton.Frame.Bottom + (View.Bounds.Height * .25f); ScrollView.ContentSize = new CGSize(0, (nfloat)Math.Max(controlBottom, View.Bounds.Height * 1.05f)); // setup the header shadow UIBezierPath shadowPath = UIBezierPath.FromRect(HeaderView.Bounds); HeaderView.Layer.MasksToBounds = false; HeaderView.Layer.ShadowColor = UIColor.Black.CGColor; HeaderView.Layer.ShadowOffset = new CGSize(0.0f, .0f); HeaderView.Layer.ShadowOpacity = .23f; HeaderView.Layer.ShadowPath = shadowPath.CGPath; if (LogoView != null) { LogoView.Layer.Position = new CoreGraphics.CGPoint((HeaderView.Bounds.Width - LogoView.Bounds.Width) / 2, 0); } BirthdatePicker.LayoutChanged( ); GenderPicker.LayoutChanged( ); GenderPicker.TogglePicker(false, false); BirthdatePicker.TogglePicker(false, false); }
// GET: Dashboard/CellPhones/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CellPhone cellPhone = CellPhones.GetByID(id); if (cellPhone == null) { return(HttpNotFound()); } return(View(cellPhone)); }
private static void BuilderPatternExample() { CellPhoneBuilder builder = new CellPhoneBuilder { Cpu = "i7", Memory = 16, MemoryCapacity = 64, MicroSdSlot = null, ScreenType = "FHD" }; CellPhone cellPhone = builder.Build(); Console.WriteLine(cellPhone); }
static void Main(string[] args) { SimCard simCard = new SimCard("+38(096)5236888"); simCard.AddContact(new Contact("Mum", "+38(096)5236845")); simCard.AddContact(new Contact("Dad", "+38(096)5236889")); Contact brother = new Contact("Brother", "+38(096)5233873"); brother.Numbers.Add("+38(093)5233779"); simCard.AddContact(brother); LandlinePhone landlinePhone = new LandlinePhone(2005); landlinePhone.Number = "596235"; ThomasEdisonPhone thomasEdisonPhone = new ThomasEdisonPhone(1980); thomasEdisonPhone.Number = "562348"; CellPhone cellphone = new CellPhone(2011, 5, simCard); Smartphone smartphone = new Smartphone(2018, 48, "Android", simCard); VideoPhone videoPhone = new VideoPhone(2017, 24, simCard); User user = new User("Daria"); Console.WriteLine("LandlinePhone"); user.CallAnotherUser("395698", landlinePhone); Console.WriteLine("*************************"); user.AcceptIncomingCall("798562", landlinePhone); Console.WriteLine("*************************"); Console.WriteLine("ThomasEdisonPhone"); user.CallAnotherUser("984256", thomasEdisonPhone); Console.WriteLine("*************************"); user.AcceptIncomingCall("658423", thomasEdisonPhone); Console.WriteLine("*************************"); Console.WriteLine("CellPhone"); user.CallAnotherUser("Mum", cellphone); Console.WriteLine("*************************"); user.AcceptIncomingCall("+38(096)5236889", cellphone); Console.WriteLine("*************************"); Console.WriteLine("Smartphone"); user.CallAnotherUser("+38(097)5428953", smartphone); Console.WriteLine("*************************"); user.AcceptIncomingCall("+38(097)5428953", smartphone); Console.WriteLine("*************************"); Console.WriteLine("VideoPhone"); user.CallAnotherUser("+38(097)5428988", videoPhone); Console.WriteLine("*************************"); user.AcceptIncomingCall("+38(097)5477753", videoPhone); Console.WriteLine("*************************"); Console.ReadLine(); }
internal void AddPerson(int originid, int?entrypointid, int?campusid) { Family f; if (FamilyId > 0) { f = Family; } else { f = new Family(); AddressInfo.CopyPropertiesTo(f); f.ResCodeId = AddressInfo.ResCode.Value.ToInt2(); f.HomePhone = HomePhone.GetDigits(); } if (NickName != null) { NickName = NickName.Trim(); } var position = DbUtil.Db.ComputePositionInFamily(Age ?? -1, MaritalStatus.Value == "20", FamilyId) ?? 10; FirstName = FirstName.Trim(); if (FirstName == "na") { FirstName = ""; } person = Person.Add(f, position, null, FirstName.Trim(), NickName, LastName.Trim(), DOB, false, Gender.Value.ToInt(), originid, entrypointid); this.CopyPropertiesTo(Person); Person.CellPhone = CellPhone.GetDigits(); if (campusid == 0) { campusid = null; } Person.CampusId = Util.PickFirst(campusid.ToString(), DbUtil.Db.Setting("DefaultCampusId", "")).ToInt2(); if (Person.CampusId == 0) { Person.CampusId = null; } DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("AddPerson {0}".Fmt(person.PeopleId)); DbUtil.Db.Refresh(RefreshMode.OverwriteCurrentValues, Person); PeopleId = Person.PeopleId; }
static void Main() { // Create an instance of CellPhone class CellPhone first = new CellPhone("5800", "Nokia"); // Create an array of CellPhone objects CellPhone[] phones = { new CellPhone("5700", "Nokia"), new CellPhone("5200", "Samsung") }; // Printing them using ToString foreach (var phone in phones) { Console.WriteLine(phone); } // Printing static CellPhone Console.WriteLine(CellPhone.IPhone4S); // AddCall to fill CallHistory first.AddCall(DateTime.Now, "555", 526); first.AddCall(DateTime.Parse("5/5/2012"), "08952626", 30); first.AddCall(DateTime.Parse("2/5/2012"), "08954626", 30); first.AddCall(DateTime.Parse("4/5/2012"), "08552626", 60); // Printing calls foreach (var item in first.CallHistory) { Console.WriteLine(item.DateTimeCall); } // Creating instance of Battery Battery bat = new Battery("Model", BatteryType.LiIon); CellPhone myNokia = new CellPhone("5800", "Nokia", 200, "Ralitsa"); // Printing myNoki Console.WriteLine(myNokia); }
public Call(){ cellPhone = new CellPhone(); }