Beispiel #1
0
        static void Main(string[] args)
        {
            Cellphone obj = new Cellphone();

            obj.Id           = 1;
            obj.Manufacturer = "Apple";
            obj.Model        = "X";
            obj.Price        = 1400;

            IFormatter    binaryFormatter = new BinaryFormatter();
            XmlSerializer xmlSerializer   = new XmlSerializer(typeof(Cellphone));

            Stream stream = new FileStream(
                @"D:\IOTest\MyFile.bin",
                FileMode.Create,
                FileAccess.Write,
                FileShare.None);
            FileStream fileStream = new FileStream(
                @"D:\IOTest\MyXMLFile.xml",
                FileMode.Create,
                FileAccess.Write,
                FileShare.None);

            binaryFormatter.Serialize(stream, obj);
            xmlSerializer.Serialize(fileStream, obj);
            stream.Close();
            fileStream.Close();
        }
Beispiel #2
0
        public IActionResult Put(int id, [FromBody] Cellphone obj)
        {
            db.Entry <Cellphone>(obj).State = EntityState.Modified;
            db.SaveChanges();

            return(new ObjectResult("Employee modified successfully!"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Make,Model,OS,ScreenSize,Memory,Price,Prepaid")] Cellphone cellphone)
        {
            if (id != cellphone.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cellphone);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CellphoneExists(cellphone.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cellphone));
        }
        public void OnWrite(IMValueWriter writer)
        {
            writer.BeginObject();

            writer.Name("id");
            writer.Value(Id);

            writer.Name("getterNumber");
            writer.Value(GetterNumber);

            writer.Name("cellphoneId");
            writer.Value(CellphoneId);

            writer.Name("cellphone");
            Cellphone.OnWrite(writer);

            writer.Name("message");
            writer.Value(Message);

            writer.Name("date");
            writer.Value(Date.ToString());


            writer.Name("isRead");
            writer.Value(IsRead);


            writer.EndObject();
        }
Beispiel #5
0
        public IActionResult Post([FromBody] Cellphone obj)
        {
            db.Cellphones.Add(obj);
            db.SaveChanges();

            return(new ObjectResult("Employee added successfully!"));
        }
        public override int AddNewListing()
        {
            Cellphone cell    = new Cellphone();
            Listing   listing = new Listing();
            //moths to expire this ad
            int months = (Category.ExpiresIn > 0) ? Category.ExpiresIn : 3;

            cell.Listing             = listing;
            cell.Listing.Title       = Title;
            cell.Listing.CategoryId  = CategoryId;
            cell.Listing.Description = Description;
            cell.Listing.Price       = Price;
            cell.Listing.Town        = Town;
            cell.Listing.Created     = DateTime.Now;
            cell.Listing.Updated     = DateTime.Now;
            cell.Listing.Status      = "live";
            cell.Listing.OwnerId     = HttpContext.Current.User.Identity.GetUserId();
            cell.Listing.Expires     = DateTime.Now.AddMonths(months);
            cell.OS          = OS;
            cell.Brand       = Brand;
            cell.CModel      = CModel;
            cell.ScreenSize  = ScreenSize;
            cell.NetworkType = NetworkType;
            cell.Condition   = Condition;
            db.Cellphones.Add(cell);
            db.SaveChanges();
            return(cell.Listing.ListingId);
        }
Beispiel #7
0
        public async Task <IActionResult> PostCellphone([FromBody] Cellphone cellphone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Cellphone.Add(cellphone);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CellphoneExists(cellphone.Imei))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetCellphone", new { id = cellphone.Imei }, cellphone));
        }
Beispiel #8
0
        public IHttpActionResult PostCellphone(Cellphone cellphone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Cellphones.Add(cellphone);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (CellphoneExists(cellphone.IMEI))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cellphone.IMEI }, cellphone));
        }
Beispiel #9
0
        public IHttpActionResult PutCellphone(int id, Cellphone cellphone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CellphoneExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #10
0
        public async Task <IActionResult> PutCellphone([FromRoute] string id, [FromBody] Cellphone cellphone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(cellphone).State = EntityState.Modified;

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

            return(NoContent());
        }
Beispiel #11
0
        public void OnPlayerPullCellphoneRequestHandler(Client sender, params object[] args)
        {
            Cellphone cellphone = sender.GetAccountEntity().CharacterEntity.CurrentCellphone;

            sender.TriggerEvent("OnPlayerPulledCellphone", cellphone.Name,
                                JsonConvert.SerializeObject(cellphone.Contacts),
                                JsonConvert.SerializeObject(cellphone.Messages));
        }
Beispiel #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            Cellphone cellphone = db.Cellphones.Find(id);

            db.Cellphones.Remove(cellphone);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #13
0
    Cellphone phonetest(Cellphone piece)
    {
        if (piece == Cellphone.Screen)
            piece = Cellphone.Case;
        else if (piece == Cellphone.Power)
            piece = Cellphone.Ram;

            return piece;
    }
        public async Task <IActionResult> Create([Bind("ID,Make,Model,OS,ScreenSize,Memory,Price,Prepaid")] Cellphone cellphone)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cellphone);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cellphone));
        }
Beispiel #15
0
        public IHttpActionResult GetCellphone(int id)
        {
            Cellphone cellphone = db.Cellphones.Find(id);

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

            return(Ok(cellphone));
        }
Beispiel #16
0
        public IActionResult Edit(int id)//Id Az asp-route-id miad inja
        {
            CellphoneAddEdit model = new CellphoneAddEdit();

            var category   = (from c in _context.categories select c).Where(c => c.Name.Contains("موبایل")).SingleOrDefault();
            int categoryId = category.CategoryId;

            //Dropdown List - Products
            model.Products = _context.products.Where(p => p.CategoryId == categoryId).Select(c => new SelectListItem
            {
                Text  = c.ProductName,
                Value = c.ProductId.ToString()
            }).ToList();

            if (id != 0)
            {
                //Dependency Injection
                using (var db = _iServiceProvider.GetRequiredService <ApplicationDbContext>())
                {
                    Cellphone cellphone = _context.cellphones.Where(p => p.ProductId == id).SingleOrDefault();
                    if (cellphone != null)
                    {
                        model.ProductId              = cellphone.ProductId;
                        model.CellphoneId            = cellphone.CellphoneId;
                        model.CameraHas              = cellphone.CameraHas;
                        model.CameraRecording        = cellphone.CameraRecording;
                        model.CameraResolution       = cellphone.CameraResolution;
                        model.ConnectionNetworks     = cellphone.ConnectionNetworks;
                        model.ConnectionTechnologies = cellphone.ConnectionTechnologies;
                        model.CpuChipset             = cellphone.CpuChipset;
                        model.CpuCore         = cellphone.CpuCore;
                        model.CpuFrequency    = cellphone.CpuFrequency;
                        model.GPU             = cellphone.GPU;
                        model.SimcardCount    = cellphone.SimcardCount;
                        model.CpuType         = cellphone.CpuType;
                        model.ScreenProtector = cellphone.ScreenProtector;
                        model.SimcardDesc     = cellphone.SimcardDesc;
                        model.StorageSupport  = cellphone.StorageSupport;
                        model.Description     = cellphone.Description;
                        model.OS               = cellphone.OS;
                        model.OSVersion        = cellphone.OSVersion;
                        model.RAM              = cellphone.RAM;
                        model.ScreenSize       = cellphone.ScreenSize;
                        model.ScreenTechnology = cellphone.ScreenTechnology;
                        model.ScreenType       = cellphone.ScreenType;
                        model.Size             = cellphone.Size;
                        model.Storage          = cellphone.Storage;
                        model.StorageType      = cellphone.StorageType;
                        model.Weight           = cellphone.Weight;
                    }
                }
            }
            return(View("Add", model));
        }
Beispiel #17
0
 public ActionResult Edit([Bind(Include = "Id,Name,SubCategory_Id")] Cellphone cellphone)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cellphone).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SubCategory_Id = new SelectList(db.Cellphone_Hardware, "Id", "Name", cellphone.SubCategory_Id);
     ViewBag.SubCategory_Id = new SelectList(db.Cellphone_Software, "Id", "Name", cellphone.SubCategory_Id);
     return(View(cellphone));
 }
Beispiel #18
0
        public void OnPlayerCellphoneEndHandler(Client sender, params object[] args)
        {
            Cellphone cellphone = sender.GetAccountEntity().CharacterEntity.CurrentCellphone;

            if (cellphone?.CurrentCall != null)
            {
                cellphone.CurrentCall.Sender.SendInfo("Rozmowa zakończona.");
                cellphone.CurrentCall.Getter.SendInfo("Rozmowa zakończona.");

                cellphone.CurrentCall = null;
            }
        }
Beispiel #19
0
        public IHttpActionResult DeleteCellphone(int id)
        {
            Cellphone cellphone = db.Cellphones.Find(id);

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

            db.Cellphones.Remove(cellphone);
            db.SaveChanges();

            return(Ok(cellphone));
        }
Beispiel #20
0
        // GET: Cellphones/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cellphone cellphone = db.Cellphones.Find(id);

            if (cellphone == null)
            {
                return(HttpNotFound());
            }
            return(View(cellphone));
        }
Beispiel #21
0
        public CellphonesViewModel(Listing ln) : base(ln)
        {
            var cellQ = from l in db.Cellphones.Include("Listing.Category")
                        where l.ListingId == ln.ListingId
                        select l;
            Cellphone cell = cellQ.FirstOrDefault();

            OS          = cell.OS;
            Brand       = cell.Brand;
            CModel      = cell.CModel;
            ScreenSize  = cell.ScreenSize;
            NetworkType = cell.NetworkType;
            Condition   = cell.Condition;
        }
Beispiel #22
0
    Cellphone phonetest(Cellphone piece)
    {
        if (piece == Cellphone.Screen)
        {
            piece = Cellphone.Case;
        }
        else if (piece == Cellphone.Power)
        {
            piece = Cellphone.Ram;
        }


        return(piece);
    }
Beispiel #23
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Add(int CellphoneId, CellphoneAddEdit model, IEnumerable <IFormFile> files)
        {
            if (ModelState.IsValid)
            {
                /***********************/
                if (CellphoneId == 0)
                {
                    //Insert
                    using (var db = _iServiceProvider.GetRequiredService <ApplicationDbContext>())
                    {
                        Cellphone cellphoneModel = AutoMapper.Mapper.Map <CellphoneAddEdit, Cellphone>(model);
                        db.cellphones.Add(cellphoneModel);
                        db.SaveChanges();
                    }
                    return(Json(new { status = "success", message = "جزییات لپ‌تاپ با موفقیت ثبت شد" }));
                }
                else
                {
                    //Update
                    using (var db = _iServiceProvider.GetRequiredService <ApplicationDbContext>())
                    {
                        Cellphone cellphoneModel = AutoMapper.Mapper.Map <CellphoneAddEdit, Cellphone>(model);
                        db.cellphones.Update(cellphoneModel);
                        db.SaveChanges();
                    }
                    return(Json(new { status = "success", message = "جزییات لپ‌تاپ  با موفقیت ویراش شد" }));
                }
            }

            var category   = (from c in _context.categories select c).Where(c => c.Name.Contains("موبایل")).SingleOrDefault();
            int categoryId = category.CategoryId;

            //Dropdown List - Products
            model.Products = _context.products.Where(p => p.CategoryId == categoryId).Select(c => new SelectListItem
            {
                Text  = c.ProductName,
                Value = c.ProductId.ToString()
            }).ToList();

            //Display Validation with Jquery Ajax
            var list = new List <string>();

            foreach (var validation in ViewData.ModelState.Values)
            {
                list.AddRange(validation.Errors.Select(error => error.ErrorMessage));
            }

            return(Json(new { status = "error", error = list }));
        }
Beispiel #24
0
        // GET: Cellphones/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cellphone cellphone = db.Cellphones.Find(id);

            if (cellphone == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SubCategory_Id = new SelectList(db.Cellphone_Hardware, "Id", "Name", cellphone.SubCategory_Id);
            ViewBag.SubCategory_Id = new SelectList(db.Cellphone_Software, "Id", "Name", cellphone.SubCategory_Id);
            return(View(cellphone));
        }
Beispiel #25
0
        static void Main(string[] args)
        {
            var cellphoneFactory = ConfigurationManager.AppSettings["CellphoneFactory"];
            var dllName          = ConfigurationManager.AppSettings["DllName"];
            var currentAssembly  = Assembly.GetExecutingAssembly();
            var codeBase         = currentAssembly.CodeBase.ToLower().Replace(currentAssembly.ManifestModule.Name.ToLower(), string.Empty);

            var            factoryAssembly = Assembly.LoadFrom(Path.Combine(codeBase, dllName));
            ProductFactory productFactory  = factoryAssembly.CreateInstance(cellphoneFactory) as ProductFactory;
            Cellphone      cellphone       = productFactory.CreateCellphone();
            UI             ui = productFactory.CreateUI();

            cellphone.WrapUI(ui);

            Console.Read();
        }
Beispiel #26
0
 public void FillCandidate(CandidateViewModel candidate)
 {
     Name.EnterText(candidate.Name);
     Email.EnterText(candidate.Email);
     CrudLink.EnterText(candidate.CrudLink);
     SkypeAddress.EnterText(candidate.SkypeAddress);
     Portfolio.EnterText(candidate.Portfolio);
     State.EnterText(candidate.State);
     City.EnterText(candidate.City);
     Cellphone.EnterText(candidate.Cellphone);
     SixEightHours.Click();
     Salary.EnterText(candidate.Salary.ToString());
     BtnBank.Click();
     FillBank(candidate);
     BtnKnow.Click();
     _knowledgePage.FillKnowledge(candidate);
 }
Beispiel #27
0
        public async Task <IActionResult> Index(int page = 1)
        {
            Cellphone model = new Cellphone();

            //LINQ to Query string
            //Join on 2 tables
            var query = (from c in _context.cellphones
                         join p in _context.products on c.ProductId equals p.ProductId

                         select new CellphoneListViewModel()
            {
                ProductId = p.ProductId,
                Name = p.ProductName,
                CellphoneId = c.CellphoneId,
                CameraHas = c.CameraHas,
                CameraRecording = c.CameraRecording,
                CameraResolution = c.CameraResolution,
                ConnectionNetworks = c.ConnectionNetworks,
                ConnectionTechnologies = c.ConnectionTechnologies,
                CpuChipset = c.CpuChipset,
                CpuCore = c.CpuCore,
                CpuFrequency = c.CpuFrequency,
                GPU = c.GPU,
                SimcardCount = c.SimcardCount,
                CpuType = c.CpuType,
                ScreenProtector = c.ScreenProtector,
                SimcardDesc = c.SimcardDesc,
                StorageSupport = c.StorageSupport,
                Description = c.Description,
                OS = c.OS,
                OSVersion = c.OSVersion,
                RAM = c.RAM,
                ScreenSize = c.ScreenSize,
                ScreenTechnology = c.ScreenTechnology,
                ScreenType = c.ScreenType,
                Size = c.Size,
                Storage = c.Storage,
                StorageType = c.StorageType,
                Weight = c.Weight,
            }).AsNoTracking().OrderBy(p => p.ProductId);

            var modelPaging = await PagingList.CreateAsync(query, 10, page);

            return(View(modelPaging));
        }
        public string GetFormattedDetails()
        {
            List <string> details = new List <string>();

            if (Institution != "")
            {
                details.Add(Institution);
            }
            if (StreetName != "")
            {
                details.Add(StreetName + (StreetNumber != "" ? Characters.FIXED_SPACE + StreetNumber : "") + (Box != "" ? Characters.FIXED_SPACE + Box : ""));
            }
            if (PostalCode != "")
            {
                details.Add(PostalCode + (Town != "" ? Characters.FIXED_SPACE + Town : ""));
            }
            if (Telephone != "" && Telephone.Equals(Fax))
            {
                if (Telephone != "")
                {
                    details.Add("T/F" + Characters.FIXED_SPACE + Telephone.Replace("-", Characters.NOBREAK_HYPHEN));
                }
            }
            else
            {
                if (Telephone != "")
                {
                    details.Add("T" + Characters.FIXED_SPACE + Telephone.Replace("-", Characters.NOBREAK_HYPHEN));
                }
                if (Fax != "")
                {
                    details.Add("F" + Characters.FIXED_SPACE + Fax.Replace("-", Characters.NOBREAK_HYPHEN));
                }
            }
            if (Cellphone != "")
            {
                details.Add("G" + Characters.FIXED_SPACE + Cellphone.Replace("-", Characters.NOBREAK_HYPHEN));
            }
            if (Email != "")
            {
                details.Add(Email);
            }

            return(string.Join(Characters.FIXED_SPACE + Characters.NOBREAK_HYPHEN + " ", details.ToArray()));
        }
Beispiel #29
0
        static void Main(string[] args)
        {
            try
            {
                var cellphone = new Cellphone();
                cellphone.OnCellphoneCalls += Call;
                cellphone.OnCellphoneCalls += Call2;

                cellphone.Call("12345-1234");
            }
            catch (AggregateException exceptions)
            {
                foreach (var ex in exceptions.InnerExceptions)
                {
                    System.Console.WriteLine(ex.InnerException);
                }
            }
        }
Beispiel #30
0
        public void OnPlayerCellphonePickUpHandler(Client sender, params object[] args)
        {
            Cellphone     cellphone     = sender.GetAccountEntity().CharacterEntity.CurrentCellphone;
            TelephoneCall telephoneCall = cellphone.CurrentCall;


            if (telephoneCall.Getter.CurrentCellphone.CurrentCall != null)
            {
                telephoneCall.Getter.SendWarning("Aby odebrać musisz zakończyć bieżące połączenie.");
                return;
            }

            //NAPI.playPlayerAnimation(telephoneCall.Getter.Client, (int)(AnimationFlags.AllowPlayerControl),
            //    "cellphone@first_person", "cellphone_call_listen_base");

            telephoneCall.Open();

            telephoneCall.Getter.SendInfo("Odebrano telefon, aby zakończyć rozmowę naciśnij klawisz END.");
            telephoneCall.Sender.SendInfo("Rozmówca odebrał telefon, aby zakończyć rozmowę naciśnij klawisz END.");
        }
        public void Add_PhoneNotNull_PhoneAdded()
        {
            //Arrange
            var phone = new Cellphone
            {
                Id           = 0,
                Manufacturer = "Apple",
                Model        = "X",
                Price        = 1500
            };

            //Act
            _cellphonesRepository.Add(phone);
            var addedPhone = _cellphonesRepository.GetAll().FirstOrDefault();

            //Assert
            Assert.NotNull(addedPhone);
            Assert.AreEqual(phone.Model, addedPhone.Model);
            Assert.AreEqual(phone.Manufacturer, addedPhone.Manufacturer);
            Assert.AreEqual(phone.Price, addedPhone.Price);
        }