Beispiel #1
0
        public bool CreateAward(CreateAwardVM award, HttpRequestBase request)
        {
            Guid imageId  = Guid.Empty;
            var  newAward = Mapper.Map <AwardDTO>(award);
            var  uploaded = request.Files["Uploaded"];

            if (uploaded == null || uploaded.ContentLength == 0)
            {
                return(false);
            }

            byte[] bytes = new byte[uploaded.ContentLength];
            uploaded.InputStream.Read(bytes, 0, uploaded.ContentLength);

            var img = new ImageDTO()
            {
                OwnerId = Guid.NewGuid(),
                Data    = bytes,
                Type    = uploaded.ContentType
            };

            imageId          = Addimage(img);
            newAward.ImageId = imageId;

            int newAwardId = awardBll.AddAward(newAward);

            return(newAwardId >= ModelRules.LowerBoundOfId);
        }
Beispiel #2
0
        public ActionResult Create(CreateAwardVM award)
        {
            if (ModelState.IsValid)
            {
                if (bllModel.CreateAward(award, Request))
                {
                    return(RedirectToAction("Index"));
                }

                ViewBag.ImageError = "Image required";

                return(View(award));
            }

            return(View(award));
        }