Example #1
0
        public IHttpActionResult Postphone(phone phone)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            this.db.phones.Add(phone);
            var phoneExists = this.db.phones.Count(e => e.phone_num == phone.phone_num) > 0;

            try
            {
                this.db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (phoneExists)
                {
                    return(this.Conflict());
                }
                throw;
            }

            return(this.CreatedAtRoute("DefaultApi", new { id = phone.phone_num }, phone));
        }
Example #2
0
 public phone Update(phone updatedNum)
 {
     _personContext.phone.Update(updatedNum);
     _personContext.SaveChanges();
     Console.WriteLine("Phone saved");
     return(updatedNum);
 }
Example #3
0
        public IHttpActionResult Postphone(phone phone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.phone.Add(phone);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (phoneExists(phone.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = phone.Id }, phone));
        }
Example #4
0
        public IHttpActionResult Putphone(string id, phone phone)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            if (id != phone.phone_num)
            {
                return(this.BadRequest());
            }

            this.db.Entry(phone).State = EntityState.Modified;
            var phoneExists = this.db.phones.Count(e => e.phone_num == id) > 0;

            try
            {
                this.db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!phoneExists)
                {
                    return(this.NotFound());
                }
                throw;
            }

            return(this.StatusCode(HttpStatusCode.NoContent));
        }
Example #5
0
        public async Task <IHttpActionResult> Putphone(int id, phone phone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != phone.id)
            {
                return(BadRequest());
            }

            db.Entry(phone).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!phoneExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #6
0
        // GET: Phones/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phone phone = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(addressIp);
                var result = await client.GetAsync("api/phone/" + id);

                if (result.IsSuccessStatusCode)
                {
                    string data = result.Content.ReadAsStringAsync().Result;
                    phone = JsonConvert.DeserializeObject <phone>(data);
                }
            }
            if (phone == null)
            {
                return(HttpNotFound());
            }
            return(View(phone));
        }
Example #7
0
        public async Task <IActionResult> Edit(int id, [Bind("phoneID,phoneNumber")] phone phone)
        {
            if (id != phone.phoneID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phone);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!phoneExists(phone.phoneID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(phone));
        }
Example #8
0
        static void Main(string[] args)
        {
            Product[] products = new Product[5];

            var productname = "Sach1";

            products[0] = new Book();


            products[0].productName  = productname;
            products[0].productId    = 0;
            products[0].productPrice = 2500;
            Console.WriteLine("Product {0} -Book: (id={1},name={2},price={3}) - computeTax = {4}", 0, products[0].productId,
                              products[0].productName, products[0].productId, products[0].productPrice);

            var productname1 = "Sach2";

            products[1] = new Book();


            products[1].productName  = productname1;
            products[1].productId    = 1;
            products[1].productPrice = 2500;
            Console.WriteLine("Product {0} -Book: (id={1},name={2},price={3}) - computeTax = {4}", 1, products[1].productId,
                              products[1].productName, products[1].productId, products[1].productPrice);

            var productname2 = "Sach3";

            products[2] = new Book();


            products[2].productName  = productname1;
            products[2].productId    = 2;
            products[2].productPrice = 2500;
            Console.WriteLine("Product {0} -Book: (id={1},name={2},price={3}) - computeTax = {4}", 2, products[2].productId,
                              products[2].productName, products[2].productId, products[2].productPrice);

            var productname3 = "phone1";

            products[3] = new phone();


            products[3].productName  = productname1;
            products[3].productId    = 3;
            products[3].productPrice = 2500;
            Console.WriteLine("Product {0} -Book: (id={1},name={2},price={3}) - computeTax = {4}", 3, products[3].productId,
                              products[3].productName, products[3].productId, products[3].productPrice);

            var productname4 = "phone2";

            products[4] = new phone();


            products[4].productName  = productname1;
            products[4].productId    = 4;
            products[4].productPrice = 2500;
            Console.WriteLine("Product {0} -Book: (id={1},name={2},price={3}) - computeTax = {4}", 4, products[4].productId,
                              products[4].productName, products[4].productId, products[4].productPrice);
        }
        public ActionResult ChiTietSanPham(int id)
        {
            phone aphone = new phone();

            aphone = banhangEntities.phones.Find(id);

            return(View(aphone));
        }
Example #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            phone phone = db.phones.Find(id);

            db.phones.Remove(phone);
            db.SaveChanges();
            TempData["SuccessMessage"] = "Record Deleted Successfuly!";
            return(RedirectToAction("Index"));
        }
Example #11
0
        public void Create(int id)
        {
            Console.WriteLine("Input phone number: ");
            phone newPhone = new phone()
            {
                number = Console.ReadLine(), type = "home", personId = id
            };

            _phoneService.Create(newPhone);
        }
Example #12
0
        public async Task <IHttpActionResult> Getphone(int id)
        {
            phone phone = await db.phones.FindAsync(id);

            if (phone == null)
            {
                return(NotFound());
            }

            return(Ok(phone));
        }
Example #13
0
 public ActionResult Edit([Bind(Include = "Brand_Name,Model_Name,Launch,Camera,Ram,Battery,Network,weight,Memory")] phone phone)
 {
     if (ModelState.IsValid)
     {
         db.Entry(phone).State = EntityState.Modified;
         db.SaveChanges();
         TempData["SuccessMessage"] = "Record Edited Successfuly!";
         return(RedirectToAction("Index"));
     }
     return(View(phone));
 }
Example #14
0
        public async Task <IActionResult> Create([Bind("phoneID,phoneNumber")] phone phone)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phone);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phone));
        }
Example #15
0
        private static void AddPhoneToConstituent(Donor d, ref constituent constt, bool setPrimary = false, bool SendToApi = false)
        {
            try
            {
                var phone = new phone
                {
                    number         = d.Phone,
                    inactive       = false,
                    primary        = setPrimary,
                    createDate     = DateTime.Now,
                    updateDate     = DateTime.Now,
                    customFieldMap = new abstractCustomizableEntityEntry[0],
                };

                //check if is null or already has phone.
                if (constt.phones == null)
                {
                    constt.phones    = new phone[1];
                    constt.phones[0] = phone;
                }
                else
                {
                    var newmax   = constt.phones.Count() + 1;
                    var newArray = new phone[newmax];
                    constt.phones.CopyTo(newArray, 0);
                    newArray[newmax - 1] = phone;
                    constt.phones        = newArray;
                }

                if (SendToApi)
                {
                    var saveOrUpdateConstituentRequest = new SaveOrUpdateConstituentRequest {
                        constituent = constt
                    };
                    _client.SaveOrUpdateConstituent(saveOrUpdateConstituentRequest);
                }
            }
            catch (FaultException exception)
            {
                Type         exType = exception.GetType();
                MessageFault mf     = exception.CreateMessageFault();
                Console.WriteLine("Error when add phone to constituent // " + exception.Message);
                if (mf.HasDetail)
                {
                    var    detailedMessage = mf.GetDetail <System.Xml.Linq.XElement>();
                    String message         = detailedMessage.FirstNode.ToString();
                    Console.WriteLine("More details // " + message);
                }
            }
            catch (Exception exc)
            {
                var txt = exc;
            }
        }
Example #16
0
        public IHttpActionResult Getphone(string id)
        {
            phone phone = db.phone.Find(id);

            if (phone == null)
            {
                return(NotFound());
            }

            return(Ok(phone));
        }
Example #17
0
        private void autho_button_Click(object sender, EventArgs e)
        {
            string text = this.authorizate_text_box.Text;

            authorizate_text_box.Text = "";

            if (text != "admin")
            {
                try{
                    int       number = Convert.ToInt32(text);
                    telephone _phone = test.data.get_phone(number);
                    if (_phone != null)
                    {
                        if (used_numbers.Contains(number))
                        {
                            MessageBox.Show("This number is used now", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                        else
                        {
                            used_numbers.Add(number);
                            phone phone_form = new phone(_phone);
                            phone_form.Show();
                            this.Visible = false;
                        }
                    }

                    else
                    {
                        MessageBox.Show("This number dont exsist", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                catch (FormatException ex) {
                    MessageBox.Show("This is not nubmer", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            else
            {
                if (is_admin)
                {
                    MessageBox.Show("There is another admin exsist", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    is_admin = true;
                    admin_form admin = new admin_form();
                    admin.Show();
                }
            }
        }
Example #18
0
        public ActionResult Create([Bind(Include = "Brand_Name,Model_Name,Launch,Camera,Ram,Battery,Network,weight,Memory")] phone phone)
        {
            if (ModelState.IsValid)
            {
                db.phones.Add(phone);
                db.SaveChanges();
                TempData["SuccessMessage"] = "New Record Added Successfuly!";
                return(RedirectToAction("Index"));
            }

            return(View(phone));
        }
        protected void grdContent_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            phone _phone = db.phones.SingleOrDefault(c => c.Id.ToString() == grdContent.Rows[e.RowIndex].Cells[0].Text);

            db.phones.DeleteOnSubmit(_phone);
            db.SubmitChanges();
            grdContent.DataSource = db.phones.Where(c => c.userid == Login.iduser).ToList();
            grdContent.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }
        protected void btndelete_Click(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            phone _phone = db.phones.SingleOrDefault(c => c.Id == id);

            db.phones.DeleteOnSubmit(_phone);
            db.SubmitChanges();
            grdContent.DataSource = db.phones.Where(c => c.userid == Login.iduser).ToList();
            grdContent.DataBind();
            txtid.Text   = null;
            txtname.Text = txtfamily.Text = txtmobile.Text = txtphonenumber.Text = "";
        }
Example #21
0
        public async Task <IHttpActionResult> Postphone(phone phone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.phones.Add(phone);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = phone.id }, phone));
        }
        protected void grdContent_SelectedIndexChanged(object sender, EventArgs e)
        {
            lingtophonebookDataContext db = new lingtophonebookDataContext();
            phone _phone = db.phones.SingleOrDefault(c => c.Id.ToString() == grdContent.SelectedRow.Cells[0].Text);

            id                  = _phone.Id;
            txtname.Text        = _phone.name;
            txtfamily.Text      = _phone.family;
            txtmobile.Text      = _phone.mobile;
            txtphonenumber.Text = _phone.phonenumber;
            // grdContent.DataSource = db.phone.Where(c => c.Id.ToString() == txtid.Text).ToList();
            // grdContent.DataBind();
        }
Example #23
0
    private void MakePhone()
    {
        //if (playerinventory.currentMagic > 0)
        //{
        Vector2 temp  = new Vector2(animation.GetFloat("Horizontal"), animation.GetFloat("Vertical"));
        phone   Phone = Instantiate(phonePro, transform.position, Quaternion.identity).GetComponent <phone>();

        Phone.Setup(temp, ChooseProjectileDirection());
        // playerinventory.ReduceMagic(Arrow.magicCost);
        // reduceMagic.Raise();

        //}
    }
Example #24
0
        public phone Update(long id, phone updatedNum)
        {
            var getPhone = Read(id);

            if (getPhone == null)
            {
                Console.WriteLine("Can't find phone -- update failed.");
                return(null);
            }
            var phones = _phoneRepository.Update(updatedNum);

            return(updatedNum);
        }
Example #25
0
        // GET: one/Details/5
        public ViewResult Details(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }
            phone phone = db.phones.FirstOrDefault(a => a.price == id);

            if (phone == null)
            {
                return(View("Error"));
            }
            return(View(phone));
        }
Example #26
0
        public async Task <IHttpActionResult> Deletephone(int id)
        {
            phone phone = await db.phones.FindAsync(id);

            if (phone == null)
            {
                return(NotFound());
            }

            db.phones.Remove(phone);
            await db.SaveChangesAsync();

            return(Ok(phone));
        }
Example #27
0
        public IHttpActionResult Deletephone(string id)
        {
            phone phone = db.phone.Find(id);

            if (phone == null)
            {
                return(NotFound());
            }

            db.phone.Remove(phone);
            db.SaveChanges();

            return(Ok(phone));
        }
Example #28
0
        // GET: phone/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            phone phone = db.phones.Find(id);

            if (phone == null)
            {
                return(HttpNotFound());
            }
            return(View(phone));
        }
Example #29
0
 public phone Create(phone newphone)
 {
     try
     {
         _personContext.phone.Add(newphone);
         _personContext.SaveChanges();
         Console.WriteLine("Phone saved");
         return(newphone);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
Example #30
0
        public ViewResult DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(View("Error"));
            }
            phone phone = db.phones.FirstOrDefault(a => a.price == id);

            if (phone == null)
            {
                return(View("Error"));
            }

            db.Delete(phone);
            return(View("Index"));
        }