Ejemplo n.º 1
0
        public ActionResult Create(AwardModel model, HttpPostedFileBase image = null)
        {
            try
            {
                if (image != null)
                {
                    model.ImageMimeType = image.ContentType;
                    model.ImageData     = new byte[image.ContentLength];
                    image.InputStream.Read(model.ImageData, 0, image.ContentLength);

                    ModelState.Remove("ImageData");
                    ModelState.Add("ImageData", new ModelState());
                    ModelState.SetModelValue("ImageData", new ValueProviderResult(new byte[image.ContentLength], "1", null));
                }


                if (!ModelState.IsValid)
                {
                    return(View());
                }

                AwardHelper.CreateEntity(model);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public void CreateAward()
        {
            var awardModel = new AwardModel
            {
                Id          = Guid.Parse("7816ec31-2185-4e0f-a32c-64d970eff009"),
                Title       = "Gold",
                Description = "The Gold",
                ImageData   =
                    BaseHelper.GetImageData(
                        "89-50-4E-47-0D-0A-1A-0A-00-00-00-0D-49-48-44-52-00-00-00-CF-00-00-00-D1-08-06-00-00-00-6B-5D-E6-B4-00-00-00-01-73-52-47-42-00-AE-CE-1C-E9-00-00-00-04-67-41-4D-41-00-00-B1-8F-0B-FC-61-05-00-00-00-09-70-48-59-73-00-00-0E-C2-00-00-0E-C2-01-15-28-4A-80-00-00-05-D6-49-44-41-54-78-5E-ED-DC-5B-72-DB-38-10-40-D1-68-16-90-FD-AF-33-1B-F0-04-35-62-D9-93-58-22-D9-7C-A0-1B-38-E7-27-FA-75-D0-57-0D-32-15-3F-3E-7E-FB-01-EC-F6-CF-F3-4F-60-27-F1-40-90-78-20-48-3C-10-24-1E-08-12-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-48-3C-10-24-1E-08-12-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-48-3C-10-24-1E-08-12-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-C8-EF-AA-BE-D9-E3-F1-78-7E-8A-71-5C-79-88-E7-02-47-03-89-72-94-F7-12-CF-09-7A-C5-B2-C6-D1-5E-4B-3C-01-59-63-59-E3-A8-CF-25-9E-8D-AA-06-F3-8A-63-3F-4E-3C-6F-5C-11-CC-C7-AF-E7-87-A0-C7-CF-E7-87-13-19-81-18-F1-7C-E3-68-34-47-03-89-3A-23-2C-E3-B0-9D-78-9E-8E-04-D3-2B-96-35-47-62-32-16-EB-A6-8F-27-1A-4D-D6-60-DE-89-C4-24-A2-D7-A6-8D-27-12-4D-C5-60-BE-23-A2-73-4C-19-CF-9E-70-46-09-E6-95-3D-21-09-E8-FF-A6-8A-47-34-AF-89-68-BF-29-E2-11-CD-76-22-DA-6E-F8-78-B6-84-33-7B-30-AF-6C-09-69-E6-80-86-8D-67-EB-B6-11-CE-7B-5B-37-D1-8C-11-0D-19-8F-6D-73-3E-5B-E8-6F-C3-C5-B3-16-8E-68-8E-59-8B-68-A6-80-86-89-C7-B6-B9-8F-2D-F4-9F-21-E2-B1-6D-FA-98-7D-0B-95-FF-1D-06-C2-E9-67-ED-EF-76-CB-6D-A0-B2-D2-F1-08-A7-BF-99-03-2A-7B-6D-7B-77-28-A2-E9-E3-DD-35-6E-C4-2B-5C-C9-CD-23-9C-9C-DE-FD-DD-8F-B8-81-CA-C5-23-9C-DC-66-0A-A8-54-3C-C2-A9-61-96-80-CA-C4-23-9C-5A-66-08-A8-44-3C-C2-A9-69-F4-80-D2-C7-23-9C-DA-46-0E-28-75-3C-C2-19-C3-A8-01-A5-8D-47-38-63-19-31-A0-32-2F-0C-16-C2-A9-6B-B4-B3-4B-19-CF-AB-6F-22-E1-D4-F7-EA-0C-2B-6E-9F-74-F1-08-67-7C-A3-04-94-2A-9E-AA-77-5F-CE-53-69-06-4A-3C-F3-D8-3A-E3-19-E1-4C-D3-C4-E3-BA-36-9F-EA-D7-B7-D4-9B-47-38-E3-AB-1C-50-8A-78-3C-EB-50-51-F7-78-5C-D7-A8-BA-7D-4A-BC-30-60-7C-15-BF-2C-BB-C6-63-EB-B0-26-F3-F6-49-B7-79-84-33-AF-6A-67-DF-2D-1E-2F-09-D8-2A-EB-AC-A4-DA-3C-B6-0E-95-66-A0-4B-3C-B6-0E-7B-65-9C-99-34-9B-C7-D6-61-51-65-16-6E-8F-C7-D6-21-2A-DB-EC-A4-D8-3C-B6-0E-7F-AA-30-13-B7-C6-63-EB-70-54-A6-19-EA-BE-79-6C-1D-5E-C9-3E-1B-69-5E-18-40-35-B7-C5-E3-CA-C6-59-B2-CC-52-D7-CD-E3-CA-C6-9A-CC-33-E2-DA-46-49-19-B6-CF-2D-F1-7C-F7-83-DA-3A-6C-95-75-56-6C-1E-08-12-0F-04-5D-1E-8F-B7-6C-5C-A5-F7-6C-75-D9-3C-9E-77-D8-2B-E3-CC-B8-B6-41-90-78-20-48-3C-94-D6-F3-B9-E7-D2-78-FC-FB-0E-67-CA-36-3B-36-0F-04-89-07-82-C4-03-41-E2-81-20-F1-50-5E-AF-37-6E-97-C5-E3-4D-1B-57-C8-34-43-36-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-48-3C-10-24-1E-08-12-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-48-3C-10-74-59-3C-1F-1F-1F-CF-4F-9F-1E-3F-9F-1F-20-E8-BB-19-FA-6E-D6-EE-60-F3-40-90-78-20-48-3C-10-24-1E-08-12-0F-04-5D-1A-8F-37-6E-9C-29-DB-EC-D8-3C-94-D6-EB-35-75-23-1E-08-12-0F-04-75-89-C7-73-0F-7B-65-9C-99-CB-E3-E9-79-27-65-6C-BD-67-CB-B5-0D-82-C4-03-41-DD-E2-F1-DC-C3-56-59-67-E5-96-78-3C-F7-70-B6-0C-33-D5-F5-DA-66-FB-50-D9-6D-F1-D8-3E-44-7C-F7-05-9B-65-96-BC-30-80-A0-EE-F1-B8-BA-F1-4A-F6-D9-B8-35-1E-57-37-8E-CA-34-43-29-AE-6D-B6-0F-7F-AA-30-13-B7-C7-63-FB-10-95-6D-76-D2-BC-30-B0-7D-58-54-99-85-2E-F1-D8-3E-EC-95-71-66-D2-6C-9E-C6-F6-A1-D2-0C-74-8B-C7-F6-61-AB-AC-B3-92-6A-F3-34-B6-CF-BC-AA-9D-7D-D7-78-6C-1F-D6-64-9E-91-74-9B-A7-B1-7D-E6-53-F1-CC-BB-C7-F3-EA-9B-45-40-F3-78-75-D6-D9-6F-26-29-37-0F-54-90-22-1E-DB-67-5E-55-B7-4E-93-66-F3-08-68-3E-95-C3-69-4A-5C-DB-04-34-9E-11-CE-34-55-3C-55-BE-71-B8-4E-A5-19-48-B7-79-5C-DF-C6-57-FD-BA-B6-48-79-6D-13-D0-B8-46-09-A7-29-F1-CC-F3-95-80-EA-1A-ED-EC-D2-C6-F3-EE-9B-48-40-F5-BC-3B-B3-8A-5B-A7-49-BD-79-04-34-86-11-C3-69-D2-5F-DB-04-54-DB-A8-E1-34-25-9E-79-04-54-D3-C8-E1-34-65-5E-18-08-A8-96-D1-C3-69-CA-C4-D3-08-A8-86-19-C2-69-4A-C5-D3-08-28-B7-59-C2-69-CA-C5-D3-08-28-A7-99-C2-69-1E-BF-7F-A8-B2-3F-D5-E3-F1-78-7E-FA-DE-C7-AF-E7-07-2E-37-5B-38-4D-E9-78-1A-01-F5-B5-B6-E9-47-0D-A7-29-79-6D-FB-6A-ED-70-5C-E3-AE-33-73-38-4D-F9-CD-B3-58-DB-40-8D-2D-74-8E-2D-5F-48-A3-87-D3-94-DF-3C-8B-76-58-6B-07-66-0B-1D-27-9C-4F-C3-6C-9E-AF-6C-A1-F3-89-E6-6F-43-C6-D3-6C-09-A8-11-D1-7B-5B-B7-F5-6C-E1-34-C3-C6-B3-B0-85-E2-6C-9B-F7-86-8F-A7-B1-85-F6-B1-6D-B6-99-22-9E-C5-D6-88-9A-D9-42-DA-1A-4C-33-7B-34-8B-A9-E2-59-88-E8-D3-9E-68-1A-E1-7C-9A-32-9E-66-4F-40-CD-68-11-89-E6-B8-69-E3-59-EC-8D-A8-A9-1A-D2-DE-60-1A-D1-BC-36-7D-3C-8B-48-44-8B-AC-31-45-62-59-18-8B-75-E2-F9-C3-91-88-16-BD-62-3A-12-CB-C2-38-6C-27-9E-37-CE-08-E9-AB-B3-A2-3A-23-92-AF-8C-40-8C-78-36-3A-3B-A4-DE-1C-FB-71-E2-09-A8-1C-92-E3-3E-8F-78-0E-CA-1E-92-E3-BD-8E-78-4E-D6-33-26-47-79-2F-F1-DC-E8-AC-B0-1C-59-0E-E2-81-A0-61-FE-27-29-DC-4D-3C-10-24-1E-08-12-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-48-3C-10-24-1E-08-12-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-48-3C-10-24-1E-08-12-0F-04-89-07-82-C4-03-41-E2-81-20-F1-40-90-78-20-48-3C-10-24-1E-08-12-0F-84-FC-F8-F1-2F-3A-03-62-F1-18-1D-ED-01-00-00-00-00-49-45-4E-44-AE-42-60-82"),
                ImageMimeType = "image/png"
            };

            var cntBefore = AwardHelper.AwardModelList.Count;

            AwardHelper.CreateEntity(awardModel);
            var cntAfter = AwardHelper.AwardModelList.Count;

            Assert.AreEqual(cntBefore + 1, cntAfter, "Error in created award...");
        }
Ejemplo n.º 3
0
        public ActionResult Create(AwardModel model, HttpPostedFileBase image = null)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                if (image != null)
                {
                    model.ImageMimeType = image.ContentType;
                    model.ImageData     = new byte[image.ContentLength];
                    image.InputStream.Read(model.ImageData, 0, image.ContentLength);
                }

                AwardHelper.CreateEntity(model);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }