Exemple #1
0
        public LabelResponse GetLabel(int id)
        {
            var label = dbContext.MusicLabel.Where(e => e.IdMusicLabel == id).FirstOrDefault();

            if (label == null)
            {
                throw new AppException("NIE MA TAKIEJ WYTWORNI O PODANYM ID!");
            }

            var albums = dbContext.Album
                         .Where(a => a.IdMusicLabel == id)
                         .OrderByDescending(d => d.PublishDate)
                         .ToList();

            var labelResponse = new LabelResponse
            {
                IdMusicLabel = label.IdMusicLabel,
                Name         = label.Name,
                Albums       = albums
            };



            return(labelResponse);
        }
Exemple #2
0
        /// <summary>
        /// Displays the labels.
        /// </summary>
        /// <param name="userID">The user identifier.</param>
        /// <returns>
        /// returns the list of label
        /// </returns>
        /// <exception cref="Exception"> exception message</exception>
        public IList <LabelResponse> DisplayLabels(string userID)
        {
            try
            {
                // get the labels data from tabel
                var data = this.authenticationContext.Label.Where(s => s.UserID == userID);

                var list = new List <LabelResponse>();

                if (data != null)
                {
                    foreach (var label in data)
                    {
                        var labels = new LabelResponse()
                        {
                            ID    = label.LabelID,
                            Label = label.Label,
                        };

                        list.Add(labels);
                    }

                    return(list);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
        public void CreateLabel()
        {
            LabelRequest labelRequest = CreateLabelRequest();

            VisibleConfig  config         = new VisibleConfig(VisibleVersion.V1, VisibleEnvironment.Sandbox);
            VisibleRequest visibleRequest = new VisibleRequest(labelRequest, "Label/Create", config);
            LabelResponse  labelResponse  = visibleRequest.Execute <LabelResponse>();

            Assert.AreEqual(0, labelResponse.ResultCode);
        }
Exemple #4
0
        private NoteResponse GetNoteResponse(string userID, NoteModel note)
        {
            try
            {
                // get labels for Note
                var labelList = this.authenticationContext.NoteLabel.Where(s => s.UserID == userID && s.NoteID == note.NoteID);

                // creating list for label
                var labels = new List <LabelResponse>();

                // iteartes the loop for each label for note
                foreach (var data in labelList)
                {
                    // get the label info
                    var label = new LabelResponse()
                    {
                        ID    = data.LabelID,
                        Label = data.Label,
                    };

                    // add the label info into label list
                    labels.Add(label);
                }

                // get the required values of note
                var notes = new NoteResponse()
                {
                    NoteID      = note.NoteID,
                    Title       = note.Title,
                    Description = note.Description,
                    Color       = note.Color,
                    Image       = note.Image,
                    IsArchive   = note.IsArchive,
                    IsPin       = note.IsPin,
                    IsTrash     = note.IsTrash,
                    Reminder    = note.Reminder,
                    Labels      = labels
                };
                // return the note info
                return(notes);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        public void CreateAndManifestShipment()
        {
            // Create label
            LabelRequest   labelRequest   = CreateLabelRequest();
            VisibleRequest visibleRequest = new VisibleRequest(labelRequest, "Label/Create");
            LabelResponse  labelResponse  = visibleRequest.Execute <LabelResponse>();

            Assert.AreEqual(0, labelResponse.ResultCode);

            // Manifest Shipment
            ShippingManifestRequest manifestRequest = CreateManifestRequest(labelResponse.TrackingNumber);

            visibleRequest = new VisibleRequest(manifestRequest, "ShippingManifest/Create");
            ShippingManifestResponse manifestResponse = visibleRequest.Execute <ShippingManifestResponse>();

            Assert.AreEqual(0, manifestResponse.ResultCode);
        }
        public void CreateAndTrackShipment()
        {
            // Create label
            LabelRequest   labelRequest   = CreateLabelRequest();
            VisibleRequest visibleRequest = new VisibleRequest(labelRequest, "Label/Create");
            LabelResponse  labelResponse  = visibleRequest.Execute <LabelResponse>();

            Assert.AreEqual(0, labelResponse.ResultCode);

            // Track Shipment
            ShipmentTrackingRequest trackingRequest = CreateTrackingRequest(labelResponse.TrackingNumber);

            visibleRequest = new VisibleRequest(trackingRequest, "Shipment/Track");
            ShipmentTrackingResponse trackingResponse = visibleRequest.Execute <ShipmentTrackingResponse>();

            Assert.AreEqual(0, trackingResponse.ResultCode);
        }
        public void CreateAndCancelLabel()
        {
            // Create label
            LabelRequest   labelRequest   = CreateLabelRequest();
            VisibleRequest visibleRequest = new VisibleRequest(labelRequest, "Label/Create");
            LabelResponse  labelResponse  = visibleRequest.Execute <LabelResponse>();

            Assert.AreEqual(0, labelResponse.ResultCode);

            // Cancel label
            CancelLabelRequest cancelLabelRequest = CreateCancelLabelRequest(labelResponse.TrackingNumber);

            visibleRequest = new VisibleRequest(cancelLabelRequest, "Label/Cancel");
            CancelLabelResponse cancelLabelResponse = visibleRequest.Execute <CancelLabelResponse>();

            Assert.AreEqual(0, cancelLabelResponse.ResultCode);
        }
Exemple #8
0
        /// <summary>
        /// Updates the label.
        /// </summary>
        /// <param name="labelRequest">The label request.</param>
        /// <param name="labelID">The label identifier.</param>
        /// <param name="userID">The user identifier.</param>
        /// <returns>
        /// returns the info of label
        /// </returns>
        /// <exception cref="Exception"> exception message</exception>
        public async Task <LabelResponse> UpdateLabel(LabelRequest labelRequest, int labelID, string userID)
        {
            try
            {
                // get the label info from label tabel

                var label = this.authenticationContext.Label.Where(s => s.LabelID == labelID && s.UserID == userID).FirstOrDefault();
                // check whether label data is null or not
                if (label != null)
                {
                    // set the current date and time for modified date property
                    label.ModifiedDate = DateTime.Now;

                    // check whether user enter label name or not
                    if (labelRequest.Label != null && labelRequest.Label != string.Empty)
                    {
                        label.Label = labelRequest.Label;
                    }

                    // update the label name
                    this.authenticationContext.Label.Update(label);
                    await this.authenticationContext.SaveChangesAsync();

                    var data = new LabelResponse()
                    {
                        ID    = label.LabelID,
                        Label = label.Label,
                    };
                    return(data);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }