コード例 #1
0
ファイル: Employee.cs プロジェクト: sofipacifico/CommonJobs
        public SlotWithAttachment AddAttachment(AttachmentReference attachmentReference, AttachmentSlot slot)
        {
            if (AttachmentsBySlot == null)
            {
                AttachmentsBySlot = new List<SlotWithAttachment>();
            }
            else if (AttachmentsBySlot.Any(x => x.SlotId == slot.Id && x.Attachment != null))
            {
                log.Dump(
                    LogLevel.Error,
                    new { slot, attachmentReference },
                    "Slot is not free");
                throw new ApplicationException(string.Format("Slot `{0}` is not free", slot.Id));
            }
            else
            {
                AttachmentsBySlot.RemoveAll(x => x.Attachment == null);
            }

            var added = new SlotWithAttachment()
            {
                Date = DateTime.Now,
                Attachment = attachmentReference,
                SlotId = slot.Id
            };

            AttachmentsBySlot.Add(added);

            return added;
        }
コード例 #2
0
ファイル: Employee.cs プロジェクト: CarlosGM/CommonJobs
        public SlotWithAttachment AddAttachment(AttachmentReference attachmentReference, AttachmentSlot slot)
        {
            if (AttachmentsBySlot == null)
            {
                AttachmentsBySlot = new List <SlotWithAttachment>();
            }
            else if (AttachmentsBySlot.Any(x => x.SlotId == slot.Id && x.Attachment != null))
            {
                log.Dump(
                    LogLevel.Error,
                    new { slot, attachmentReference },
                    "Slot is not free");
                throw new ApplicationException(string.Format("Slot `{0}` is not free", slot.Id));
            }
            else
            {
                AttachmentsBySlot.RemoveAll(x => x.Attachment == null);
            }

            var added = new SlotWithAttachment()
            {
                Date       = DateTime.Now,
                Attachment = attachmentReference,
                SlotId     = slot.Id
            };

            AttachmentsBySlot.Add(added);

            return(added);
        }