/// <summary>
        /// Create a New Label in the Database
        /// </summary>
        /// <param name="label">Label Data</param>
        /// <param name="userId">user Id</param>
        /// <returns>Label Responses</returns>
        public async Task <LabelResponseModel> CreateLabel(LabelRequest label, int userId)
        {
            try
            {
                if (label != null || !string.IsNullOrWhiteSpace(label.Name))
                {
                    var labelData = new LabelDetails
                    {
                        UserId     = userId,
                        Name       = label.Name,
                        CreatedAt  = DateTime.Now,
                        ModifiedAt = DateTime.Now
                    };

                    _applicationContext.LabelDetails.Add(labelData);
                    await _applicationContext.SaveChangesAsync();

                    var labelResponse = new LabelResponseModel
                    {
                        LabelId    = labelData.LabelId,
                        Name       = labelData.Name,
                        CreatedAt  = labelData.CreatedAt,
                        ModifiedAt = labelData.ModifiedAt
                    };

                    return(labelResponse);
                }
                return(null);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        /// <summary>
        /// Delete a Label From the database
        /// </summary>
        /// <param name="labelId">Label Id</param>
        /// <returns>Return true if deleted Successful or else false</returns>
        public async Task <bool> DeleteLabel(int labelId)
        {
            try
            {
                List <NotesLabel> notesLabels = _applicationContext.NotesLabels.Where(label => label.LabelId == labelId).ToList();

                if (notesLabels != null && notesLabels.Count != 0)
                {
                    _applicationContext.NotesLabels.RemoveRange(notesLabels);
                    await _applicationContext.SaveChangesAsync();
                }

                LabelDetails labelDetails = _applicationContext.LabelDetails.FirstOrDefault(note => note.LabelId == labelId);

                if (labelDetails != null)
                {
                    _applicationContext.LabelDetails.Remove(labelDetails);
                    await _applicationContext.SaveChangesAsync();

                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        /// <summary>
        /// Update the Label in the Database.
        /// </summary>
        /// <param name="updateLabel">Label Data</param>
        /// <param name="LabelId">Label Id</param>
        /// <returns>Update Label Data</returns>
        public async Task <LabelResponseModel> UpdateLabel(LabelRequest updateLabel, int LabelId)
        {
            try
            {
                LabelDetails labelDetails = _applicationContext.LabelDetails.FirstOrDefault(label => label.LabelId == LabelId);

                if (labelDetails != null)
                {
                    labelDetails.Name       = updateLabel.Name;
                    labelDetails.ModifiedAt = DateTime.Now;

                    var data = _applicationContext.LabelDetails.Attach(labelDetails);
                    data.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    await _applicationContext.SaveChangesAsync();

                    var labelResponse = new LabelResponseModel
                    {
                        LabelId    = labelDetails.LabelId,
                        Name       = labelDetails.Name,
                        CreatedAt  = labelDetails.CreatedAt,
                        ModifiedAt = labelDetails.ModifiedAt
                    };

                    return(labelResponse);
                }
                return(null);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Esempio n. 4
0
 private void FillModel(LabelDetails ld)
 {
     LabelWidthSpinEdit.EditValue      = ld.Width;
     LabelHeightSpinEdit.EditValue     = ld.Height;
     VerticalPitchSpinEdit.EditValue   = ld.VPitch;
     HorizontalPitchSpinEdit.EditValue = ld.HPitch;
     BottomMarginSpinEdit.EditValue    = ld.BottomMargin;
     TopMarginSpinEdit.EditValue       = ld.TopMargin;
     LeftMarginSpinEdit.EditValue      = ld.LeftMargin;
     RightMarginSpinEdit.EditValue     = ld.RightMargin;
     UnitComboBox.EditValue            = ld.Unit;
 }
Esempio n. 5
0
        private void LookUpProductNumber_EditValueChanged(object sender, EventArgs e)
        {
            var gridLookUpEdt = (sender as GridLookUpEdit);
            var selectedRow   = gridLookUpEdt.GetSelectedDataRow();

            if (selectedRow == null)
            {
                return;
            }
            LabelDetails ld = selectedRow as LabelDetails;

            lookUpPaperType.EditValue = ld.PaperKindId;
            FillModel(ld);
        }
Esempio n. 6
0
        public IHttpActionResult GetLabelInfo(LabelRecoveryDto LabelRecovery)
        {
            LabelResponeDto LableRespone = new LabelResponeDto();

            if (LabelRecovery.LabelRequest.LabelType == "JPG")
            {
                var labelInfo = new APIShipmentRepository().GetLabelInfo(LabelRecovery.LabelRequest);
                LableRespone.LabelDetail = new List <LabelDetails>();

                foreach (var item in labelInfo)
                {
                    var pdfFileName = AppSettings.LabelVirtualPath + "/PackageLabel/" + item.DirectShipmentId + "/" + item.Image;
                    var lableDeatil = new LabelDetails();
                    lableDeatil.LabelUrl   = pdfFileName;
                    lableDeatil.LabelName  = item.Image;
                    lableDeatil.TrackingNo = item.TrackingNo;
                    lableDeatil.LabelType  = ".jpg";
                    LableRespone.LabelDetail.Add(lableDeatil);
                }
                if (labelInfo.Count > 0)
                {
                    LableRespone.Status      = true;
                    LableRespone.Discription = "Lable Information Recevied Successfully.";
                    LableRespone.TrackingNo  = labelInfo.FirstOrDefault().UniqueTrackingNumber;
                }
            }
            if (LabelRecovery.LabelRequest.LabelType == "PDF")
            {
                var lableinfo = new APIShipmentRepository().GetLabelInfo(LabelRecovery.LabelRequest);
                LableRespone.LabelDetail = new List <LabelDetails>();
                foreach (var item in lableinfo)
                {
                    item.Image = item.Image.Replace(".jpg", ".pdf");
                    var pdfFileName = AppSettings.LabelVirtualPath + "/PackageLabel/" + item.DirectShipmentId + "/" + item.Image;
                    var lableDeatil = new LabelDetails();
                    lableDeatil.LabelUrl   = pdfFileName;
                    lableDeatil.TrackingNo = item.TrackingNo;
                    lableDeatil.LabelType  = "PDF";
                    LableRespone.LabelDetail.Add(lableDeatil);
                }
                if (lableinfo.Count > 0)
                {
                    LableRespone.Status      = true;
                    LableRespone.Discription = "Lable Information Recevied Successfully.";
                    LableRespone.TrackingNo  = lableinfo.FirstOrDefault().UniqueTrackingNumber;
                }
            }
            return(Ok(LableRespone));
        }