public ActionResult VendorNoteAdd(int vendorId, string message)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            var vendor = _vendorService.GetVendorById(vendorId);

            if (vendor == null)
            {
                return(Json(new { Result = false }, JsonRequestBehavior.AllowGet));
            }

            var vendorNote = new VendorNote
            {
                Note         = message,
                CreatedOnUtc = DateTime.UtcNow,
            };

            vendor.VendorNotes.Add(vendorNote);
            _vendorService.UpdateVendor(vendor);

            return(Json(new { Result = true }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage VendorNoteAdd(HttpRequestMessage request, int vendorId, string message)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = request.CreateErrorResponse(HttpStatusCode.NotFound, "No items found");
                if (true)
                {
                    var vendor = _vendorService.GetVendorById(vendorId);
                    if (vendor == null)
                    {
                        response = request.CreateResponse(HttpStatusCode.OK, new { Result = false });
                        return response;
                    }

                    var vendorNote = new VendorNote
                    {
                        Note = message,
                        CreatedOnUtc = DateTime.UtcNow,
                    };
                    vendor.VendorNotes.Add(vendorNote);
                    _vendorService.UpdateVendor(vendor);

                    _baseService.Commit();
                    response = request.CreateResponse(HttpStatusCode.OK, new { Result = true });
                }
                return response;
            }));
        }
Ejemplo n.º 3
0
        public ActionResult VendorNoteAdd(int vendorId, string message)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            var vendor = _vendorService.GetVendorById(vendorId);

            if (vendor == null)
            {
                return(Json(new { Result = false }, JsonRequestBehavior.AllowGet));
            }

            var vendorNote = new VendorNote
            {
                Id           = vendor.VendorNotes.Count > 0 ? vendor.VendorNotes.Max(x => x.Id) + 1 : 1,
                _id          = ObjectId.GenerateNewId().ToString(),
                Note         = message,
                VendorId     = vendorId,
                CreatedOnUtc = DateTime.UtcNow,
            };

            vendor.VendorNotes.Add(vendorNote);
            _vendorService.UpdateVendor(vendor);

            return(Json(new { Result = true }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public virtual IActionResult VendorNoteAdd(int vendorId, string message)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            //try to get a vendor with the specified id
            var vendor = _vendorService.GetVendorById(vendorId);

            if (vendor == null)
            {
                return(Json(new { Result = false }));
            }

            var vendorNote = new VendorNote
            {
                Note         = message,
                CreatedOnUtc = DateTime.UtcNow
            };

            vendor.VendorNotes.Add(vendorNote);
            _vendorService.UpdateVendor(vendor);

            return(Json(new { Result = true }));
        }
Ejemplo n.º 5
0
        public virtual IActionResult VendorNoteAdd(int vendorId, string message)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors))
            {
                return(AccessDeniedView());
            }

            //try to get a vendor with the specified id
            var vendor = _vendorService.GetVendorById(vendorId);

            if (vendor == null)
            {
                return(ErrorJson("Vendor cannot be loaded"));
            }

            if (string.IsNullOrEmpty(message))
            {
                return(ErrorJson(_localizationService.GetResource("Admin.Vendors.VendorNotes.Fields.Note.Validation")));
            }

            var vendorNote = new VendorNote
            {
                Note         = message,
                CreatedOnUtc = DateTime.UtcNow
            };

            vendor.VendorNotes.Add(vendorNote);
            _vendorService.UpdateVendor(vendor);

            return(Json(new { Result = true }));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Formats the vendor note text
        /// </summary>
        /// <param name="vendorNote">Vendor note</param>
        /// <returns>Formatted text</returns>
        public static string FormatVendorNoteText(this VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException("vendorNote");
            }

            return(FormatText.ConvertText(vendorNote.Note));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Deletes a vendor note
        /// </summary>
        /// <param name="vendorNote">The vendor note</param>
        public virtual void DeleteVendorNote(VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException("vendorNote");
            }

            _vendorNoteRepository.Delete(vendorNote);
            //_unitOfWork.Commit();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Deletes a vendor note
        /// </summary>
        /// <param name="vendorNote">The vendor note</param>
        public virtual void DeleteVendorNote(VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new UserFriendlyException("vendor不存在");
            }

            _vendorNoteRepository.Delete(vendorNote);

            //event notification
            //_eventPublisher.EntityDeleted(vendorNote);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Deletes a vendor note
        /// </summary>
        /// <param name="vendorNote">The vendor note</param>
        public virtual void DeleteVendorNote(VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException(nameof(vendorNote));
            }

            _vendorNoteRepository.Delete(vendorNote);

            //event notification
            _eventPublisher.EntityDeleted(vendorNote);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Deletes a vendor note
        /// </summary>
        /// <param name="vendorNote">The vendor note</param>
        /// <param name="vendorId">Vendor ident</param>
        public virtual async Task DeleteVendorNote(VendorNote vendorNote, string vendorId)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException(nameof(vendorNote));
            }

            await _vendorRepository.PullFilter(vendorId, x => x.VendorNotes, x => x.Id, vendorNote.Id);

            //event notification
            await _mediator.EntityDeleted(vendorNote);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Insert vendor note
        /// </summary>
        /// <param name="vendorNote"></param>
        /// <param name="vendorId"></param>
        /// <returns></returns>
        public virtual async Task InsertVendorNote(VendorNote vendorNote, string vendorId)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException(nameof(vendorNote));
            }

            await _vendorRepository.AddToSet(vendorId, x => x.VendorNotes, vendorNote);

            //event notification
            await _mediator.EntityInserted(vendorNote);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Deletes a vendor note
        /// </summary>
        /// <param name="vendorNote">The vendor note</param>
        public virtual async Task DeleteVendorNote(VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException("vendorNote");
            }

            var updatebuilder = Builders <Vendor> .Update;
            var update        = updatebuilder.Pull(p => p.VendorNotes, vendorNote);
            await _vendorRepository.Collection.UpdateOneAsync(new BsonDocument("_id", vendorNote.VendorId), update);

            //event notification
            await _mediator.EntityDeleted(vendorNote);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Insert vendor note
        /// </summary>
        /// <param name="vendorNote"></param>
        /// <param name="vendorId"></param>
        /// <returns></returns>
        public virtual async Task InsertVendorNote(VendorNote vendorNote, string vendorId)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException(nameof(vendorNote));
            }

            var updatebuilder = Builders <Vendor> .Update;
            var update        = updatebuilder.AddToSet(p => p.VendorNotes, vendorNote);
            await _vendorRepository.Collection.UpdateOneAsync(new BsonDocument("_id", vendorId), update);

            //event notification
            await _mediator.EntityInserted(vendorNote);
        }
Ejemplo n.º 14
0
        public virtual void InsertVendorNote(VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException("vendorNote");
            }

            var updatebuilder = Builders <Vendor> .Update;
            var update        = updatebuilder.AddToSet(p => p.VendorNotes, vendorNote);

            _vendorRepository.Collection.UpdateOneAsync(new BsonDocument("_id", vendorNote.VendorId), update);

            //event notification
            _eventPublisher.EntityInserted(vendorNote);
        }
Ejemplo n.º 15
0
        private void VendorNoteAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
        {
            TargetViewId = "VendorNotePopup_DetailView";
            IObjectSpace objectSpace = Application.CreateObjectSpace();
            VendorNote   note        = objectSpace.CreateObject <VendorNote>();

            note.Vendors = objectSpace.GetObject <Vendor>((Vendor)View.CurrentObject);
            note.Text    = "test";


            e.View = Application.CreateDetailView(objectSpace, TargetViewId, true, note);


            e.View.Caption = e.View.Caption + " - " + note.Vendors.VendorName;
        }
        public virtual async Task<bool> InsertVendorNote(string vendorId, string message)
        {
            var vendor = await _vendorService.GetVendorById(vendorId);
            if (vendor == null)
                return false;

            var vendorNote = new VendorNote {
                Note = message,
                VendorId = vendorId,
                CreatedOnUtc = DateTime.UtcNow,
            };
            vendor.VendorNotes.Add(vendorNote);
            await _vendorService.UpdateVendor(vendor);

            return true;
        }
Ejemplo n.º 17
0
        public void Can_save_and_load_vendorNote()
        {
            var on = new VendorNote
            {
                Vendor       = GetTestVendor(),
                Note         = "Note1",
                CreatedOnUtc = new DateTime(2010, 01, 01),
            };

            var fromDb = SaveAndLoadEntity(on);

            fromDb.ShouldNotBeNull();
            fromDb.Note.ShouldEqual("Note1");
            fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));

            fromDb.Vendor.ShouldNotBeNull();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Formats the vendor note text
        /// </summary>
        /// <param name="vendorNote">Vendor note</param>
        /// <returns>Formatted text</returns>
        public static string FormatVendorNoteText(this VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException("vendorNote");
            }

            string text = vendorNote.Note;

            if (String.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            text = HtmlHelper.FormatText(text);

            return(text);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Formats the vendor note text
        /// </summary>
        /// <param name="vendorNote">Vendor note</param>
        /// <returns>Formatted text</returns>
        public virtual string FormatVendorNoteText(VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new ArgumentNullException(nameof(vendorNote));
            }

            var text = vendorNote.Note;

            if (string.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            text = HtmlHelper.FormatText(text, false, true, false, false, false, false);

            return(text);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Formats the vendor note text
        /// </summary>
        /// <param name="vendorNote">Vendor note</param>
        /// <returns>Formatted text</returns>
        public static string FormatVendorNoteText(this VendorNote vendorNote)
        {
            if (vendorNote == null)
            {
                throw new UserFriendlyException("vendorNote不存在");
            }

            string text = vendorNote.Note;

            if (String.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            text = HtmlHelper.FormatText(text, false, true, false, false, false, false);

            return(text);
        }
Ejemplo n.º 21
0
        public virtual bool InsertVendorNote(string vendorId, string message)
        {
            var vendor = _vendorService.GetVendorById(vendorId);

            if (vendor == null)
            {
                return(false);
            }

            var vendorNote = new VendorNote
            {
                Note         = message,
                VendorId     = vendorId,
                CreatedOnUtc = DateTime.UtcNow,
            };

            vendor.VendorNotes.Add(vendorNote);
            _vendorService.UpdateVendor(vendor);

            return(true);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Deletes a vendor note
 /// </summary>
 /// <param name="vendorNote">The vendor note</param>
 public virtual void DeleteVendorNote(VendorNote vendorNote)
 {
     _vendorNoteRepository.Delete(vendorNote);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Deletes a vendor note
 /// </summary>
 /// <param name="vendorNote">The vendor note</param>
 public void DeleteVendorNote([FromBody] VendorNote vendorNote)
 {
     _vendorService.DeleteVendorNote(vendorNote);
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Inserts a vendor note
 /// </summary>
 /// <param name="vendorNote">Vendor note</param>
 /// <returns>A task that represents the asynchronous operation</returns>
 public virtual async Task InsertVendorNoteAsync(VendorNote vendorNote)
 {
     await _vendorNoteRepository.InsertAsync(vendorNote);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Deletes a vendor note
 /// </summary>
 /// <param name="vendorNote">The vendor note</param>
 /// <returns>A task that represents the asynchronous operation</returns>
 public virtual async Task DeleteVendorNoteAsync(VendorNote vendorNote)
 {
     await _vendorNoteRepository.DeleteAsync(vendorNote);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Inserts a vendor note
 /// </summary>
 /// <param name="vendorNote">Vendor note</param>
 public virtual void InsertVendorNote(VendorNote vendorNote)
 {
     _vendorNoteRepository.Insert(vendorNote);
 }