Пример #1
0
        public ActionResult Edit([Bind(Exclude = "Image")] RegisterHeader registerHeader, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    if (Extensions.Extensions.CheckImageType(Image) && Extensions.Extensions.CheckImageSize(Image, 10))
                    {
                        registerHeader.Image = Extensions.Extensions.SaveImage(Server.MapPath("~/Public/images"), Image);


                        db.Entry(registerHeader).State = EntityState.Modified;
                        db.SaveChanges();

                        return(RedirectToAction("Index", "RegisterHeader"));
                    }
                    else
                    {
                        ModelState.AddModelError("Image", "The type of image is incorrect or the size of image is greater than 10 Mb.");
                    }
                }
                else
                {
                    ModelState.AddModelError("Image", "Please choose an image");
                }
            }
            return(View());
        }
Пример #2
0
        public static void RegisterToMaster()
        {
            if (StorageProvider.GetInstance().GetTokenAsSlave() != "")
            {
                return;
            }

            RegisterHeader rh = new RegisterHeader
            {
                Ip   = ConfigReader.GetInstance().Config.PredefinedIP,
                Port = ConfigReader.GetInstance().Config.Port
            };

            WraperHeader wraperHeader = new WraperHeader
            {
                Data = ByteArrayUtils.ToByteArray(rh),
                Type = HeaderTypes.RegisterHeader
            };

            TcpClient client = new TcpClient(ConfigReader.GetInstance().Config.Ip, ConfigReader.GetInstance().Config.MastersPort);

            Sender.Send(wraperHeader, client);

            new Reciever().ProcessClient(client);
        }
Пример #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound("ID is missing"));
            }

            RegisterHeader registerHeader = db.RegisterHeaders.Find(id);

            if (registerHeader == null)
            {
                return(HttpNotFound("ID was not found"));
            }

            return(View(registerHeader));
        }