Ejemplo n.º 1
0
        public bool SaveFileUploadDetails([FromBody] SaveFileUploadDetails fileUploadDetails)
        {
            bool result = false;

            //getting the elements to upload...
            switch (fileUploadDetails.AttachmentType)
            {
            case AttachmentType.GeneralInformation:
                var generalInformation = _coreRepository.Get <GeneralInformation>(fileUploadDetails.Id);
                var attachments        = new List <GeneralInformationAttachment>();
                foreach (Attachment file in fileUploadDetails.Files)
                {
                    var attach = new GeneralInformationAttachment();
                    if (file.Id > 0)
                    {
                        attach = _coreRepository.Get <GeneralInformationAttachment>(file.Id) ??
                                 new GeneralInformationAttachment();
                    }

                    attach.UserFriendlyName   = file.FriendlyName;
                    attach.FileName           = file.Name;
                    attach.FileType           = Path.GetExtension(file.Name).Trim().Replace(".", "").ToLowerInvariant();
                    attach.GeneralInformation = generalInformation;
                    attach.OriginalFileName   = file.OriginalFileName;
                    attachments.Add(attach);
                }

                result = _coreRepository.SaveOrUpdateAll(attachments);
                break;

            case AttachmentType.InformationDesk:

                break;
            }

            return(result);
        }