コード例 #1
0
ファイル: VisitasController.cs プロジェクト: jump720/MMS
        private async Task <bool> UploadPhotos(int Id, IEnumerable <HttpPostedFileBase> Photos, int porder)
        {
            int order = porder;

            foreach (var file in Photos)
            {
                if (file != null && file.ContentLength > 0)
                {
                    VisitaFoto vf = new VisitaFoto();
                    vf.VisitaId = Id;
                    vf.Order    = order++;
                    vf.Foto     = Fn.ConvertToByte(file);
                    //da.FileName = file.FileName;
                    vf.MediaType = file.ContentType;
                    db.VisitaFoto.Add(vf);
                }
            }


            if (db.VisitaFoto.Local.Count > 0)
            {
                await db.SaveChangesAsync();
            }

            return(true);
        }
コード例 #2
0
        public async Task <IHttpActionResult> AddFoto(VisitaFoto visitaFoto)
        {
            try
            {
                db.VisitaFoto.Add(visitaFoto);
                await db.SaveChangesAsync();

                visitaFoto.Foto = null;
                AddLog("VisitasAddFoto", visitaFoto.VisitaId, visitaFoto);

                return(Ok(new AjaxResult()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }