Пример #1
0
        public ActionResult Attach(string id)
        {
            var entity = RavenSession.Load <object>(id);

            if (entity == null)
            {
                return(HttpNotFound("Specified entity does not exists"));
            }

            using (var attachmentReader = new RequestAttachmentReader(Request))
            {
                if (attachmentReader.Count != 1)
                {
                    throw new NotSupportedException("One and only one attachment is required.");
                }

                var attachment = attachmentReader.First();

                var result = ExecuteCommand(new SaveAttachment(
                                                entity,
                                                attachment.Key,
                                                attachment.Value));

                return(Json(new { success = true, attachment = result }));
            }
        }
Пример #2
0
        public ActionResult SavePhoto(string id)
        {
            var applicant = RavenSession.Load <Applicant>(id);

            using (var attachmentReader = new RequestAttachmentReader(Request))
            {
                if (attachmentReader.Count != 1)
                {
                    throw new NotSupportedException("One and only one photo is required.");
                }

                var attachment = attachmentReader.First();

                applicant.Photo = ExecuteCommand(new SavePhotoAttachments(
                                                     applicant,
                                                     attachment.Key,
                                                     attachment.Value));
                return(Json(new { success = true, attachment = applicant.Photo }));
            }
        }
Пример #3
0
        public ActionResult Attach(string id)
        {
            var entity = RavenSession.Load<object>(id);
            if (entity == null)
                return HttpNotFound("Specified entity does not exists");

            using (var attachmentReader = new RequestAttachmentReader(Request))
            {
                if (attachmentReader.Count != 1)
                    throw new NotSupportedException("One and only one attachment is required.");

                var attachment = attachmentReader.First();

                var result = ExecuteCommand(new SaveAttachment(
                    entity,
                    attachment.Key,
                    attachment.Value));

                return Json(new { success = true, attachment = result });
            }
        }
        public ActionResult SavePhoto(string id, string fileName)
        {
            var employee = RavenSession.Load<Employee>(id);

            using (var attachmentReader = new RequestAttachmentReader(Request))
            {
                if (attachmentReader.Count != 1)
                    throw new NotSupportedException("One and only one photo is required.");

                var attachment = attachmentReader.First();

                employee.Photo = ExecuteCommand(new SavePhotoAttachments(
                    employee,
                    attachment.Key,
                    attachment.Value));
                return Json(new { success = true, attachment = employee.Photo });
            }
        }