public IActionResult createcatalogue(IFormFile file, string itemName, string itemDesc,
                                      int winShapeID, int companyID, decimal itemPrice, int itemID = 0)
 {
     try
     {
         //! Make Model object
         var catalogue = new CatalogueModel()
         {
             CompanyId  = companyID,
             Itemdesc   = itemDesc,
             ItemId     = itemID,
             Itemname   = itemName,
             Itemprice  = itemPrice,
             WinshapeId = winShapeID,
             PicFile    = file
         };
         if (catalogue.PicFile != null)
         {
             using (var binaryStream = new BinaryReader(catalogue.PicFile.OpenReadStream()))
             {
                 byte[] fileData = binaryStream.ReadBytes((int)catalogue.PicFile.Length);
                 catalogue.Itempic = fileData;
             }
         }
         string strMessage = string.Empty;
         bool   bFlag      = _catalogueService.CreateCatalogue(catalogue, out strMessage);
         return(Ok(new { status = bFlag ? Constants.Success : Constants.Error, message = strMessage }));
     }
     catch (Exception ex)
     {
         return(Ok(new { status = Constants.Error, message = Constants.ErrorMessage }));
     }
 }
Example #2
0
 /// <summary>
 /// Fetch the catalogue details
 /// </summary>
 /// <param name="itemID"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public CatalogueModel GetCatalogue(int itemID, out string message)
 {
     try
     {
         message = string.Empty;
         var catalogueEntity = _catalogueRepository.Get(itemID);
         if (catalogueEntity != null)
         {
             var catalogue = new CatalogueModel()
             {
                 CompanyId  = catalogueEntity.Companyid ?? 0,
                 Itemdesc   = catalogueEntity.Itemdesc,
                 ItemId     = catalogueEntity.Itemid,
                 Itemname   = catalogueEntity.Itemname,
                 Itemprice  = catalogueEntity.Itemprice ?? 0,
                 WinshapeId = catalogueEntity.Winshapeid ?? 0,
                 Itempic    = catalogueEntity.Itempic
             };
             message = "Catalogue Found.";
             return(catalogue);
         }
     }
     catch (Exception)
     {
         //! Need to log the exception.
     }
     message = "No catalogue found for given id.";
     return(null);
 }
Example #3
0
        public PartialViewResult CatalogueItems(CatalogueViewTypeEnum viewType, Guid?genreId, string searchQuery,
                                                int lastRowIndex = 0)
        {
            CatalogueModel model = GetDataModel(viewType, genreId, searchQuery, lastRowIndex);

            return(PartialView(model));
        }
Example #4
0
        void ucMenuList_btnRemove_Click(object sender, EventArgs e)
        {
            frmConfirm frmcon = new frmConfirm("Warning", "Do you want remove this menu ?");

            frmcon.ShowDialog();
            if (frmcon.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                Button         btnRemove = (Button)sender;
                CatalogueModel tag       = (CatalogueModel)(btnRemove.Tag);
                if (tag.CatalogueID > 0)
                {
                    var result = CatalogeService.RemoveCatalogue(tag.CatalogueID, 0);
                    if (result == 1)
                    {
                        addMenuList("Menu List", 1);
                        pnDetail.Controls.Clear();
                        frmMessager frm = new frmMessager("Messenger", "Delete menu successful.");
                        frmOpacity.ShowDialog(this, frm);
                    }
                    else
                    {
                        frmMessager frm = new frmMessager("Messenger", "Delete menu fail.");
                        frmOpacity.ShowDialog(this, frm);
                    }
                }
            }
        }
Example #5
0
 /// <summary>
 /// Return image not found catalogue
 /// </summary>
 /// <returns></returns>
 public CatalogueModel GetImageNotFoundCatalogue()
 {
     try
     {
         var catalogueEntity = _catalogueRepository.FindByCondition(x => x.Itemname == "SystemImageNotFound").FirstOrDefault();
         if (catalogueEntity != null)
         {
             var catalogue = new CatalogueModel()
             {
                 CompanyId  = catalogueEntity.Companyid ?? 0,
                 Itemdesc   = catalogueEntity.Itemdesc,
                 ItemId     = catalogueEntity.Itemid,
                 Itemname   = catalogueEntity.Itemname,
                 Itemprice  = catalogueEntity.Itemprice ?? 0,
                 WinshapeId = catalogueEntity.Winshapeid ?? 0,
                 Itempic    = catalogueEntity.Itempic
             };
             return(catalogue);
         }
         return(null);
     }
     catch (Exception)
     {
         //! Need to log the exception.
     }
     return(null);
 }
Example #6
0
        public int SavaDataCatalogue(CatalogueModel cata)
        {
            try
            {
                if (cata.CatalogueID == 0)
                {
                    var checkdata = _context.CATALOGUEs.Where(x => x.CatalogueName == cata.CatalogueName).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }

                    var data = new CATALOGUE();
                    data.CatalogueName = cata.CatalogueName;
                    data.Color         = cata.Color ?? "";
                    data.Status        = 1;
                    data.CreateBy      = cata.CreateBy ?? 0;
                    data.CreateDate    = DateTime.Now;
                    data.UpdateBy      = cata.UpdateBy ?? 0;
                    data.UpdateDate    = DateTime.Now;
                    data.Note          = cata.Note ?? "";

                    _context.Entry(data).State = EntityState.Added;
                    _context.SaveChanges();

                    return(1);
                }
                else
                {
                    var checkdata = _context.CATALOGUEs.Where(x => x.CatalogueName == cata.CatalogueName && x.CatalogueID != cata.CatalogueID).ToList();
                    if (checkdata.Count() > 0)
                    {
                        return(-1);
                    }
                    var data = _context.CATALOGUEs.Find(cata.CatalogueID);
                    if (data != null)
                    {
                        data.CatalogueName = cata.CatalogueName;
                        data.Color         = cata.Color ?? "";
                        data.Status        = 1;
                        data.UpdateBy      = cata.UpdateBy ?? 0;
                        data.UpdateDate    = DateTime.Now;
                        data.Note          = cata.Note ?? "";

                        _context.Entry(data).State = EntityState.Modified;
                        _context.SaveChanges();

                        return(1);
                    }
                    return(0);
                }
            }
            catch (Exception)
            {
                return(0);
            }
        }
Example #7
0
        public ActionResult Index(CatalogueViewTypeEnum viewType, Guid?genreId, string searchQuery,
                                  int lastRowIndex = 0)
        {
            CatalogueModel model = GetDataModel(viewType, genreId, searchQuery, lastRowIndex);

            if (!string.IsNullOrEmpty(searchQuery) && model.FrontViewTotalCount == 0 && model.BackViewTotalCount > 0)
            {
                return(RedirectToAction("Index", "Catalogue", new { viewType = viewType == CatalogueViewTypeEnum.Books ? CatalogueViewTypeEnum.Authors.ToString().ToLower() : CatalogueViewTypeEnum.Books.ToString().ToLower(), genreId, searchQuery }));
            }
            return(View(model));
        }
Example #8
0
        public virtual ActionResult SubmitCatalogue(CatalogueModel model)
        {
            var Submit   = RESTHelper.Post <ResultModel <ResponseModel> >(ConfigurationManager.AppSettings["HostAPIURL"] + ConfigurationManager.AppSettings["AddCatalogue"], model);
            var response = "Success Insert Product";

            if (Submit.StatusCode != (int)HttpStatusCode.OK)
            {
                response = Submit.StatusMessage;
            }
            TempData["StatusMessage"] = response;
            return(RedirectToAction(MVC.Home.Index()));
        }
        public async Task <CatalogueModel> CreateCatalogue(CatalogueModel model)
        {
            var message = new HttpRequestBuilder(settings.BaseAddress)
                          .SetPath(settings.CataloguePath)
                          .HttpMethod(HttpMethod.Post)
                          .GetHttpMessage();

            var json = JsonConvert.SerializeObject(model);

            message.Content = new StringContent(json, Encoding.UTF8, "application/json");

            return(await SendRequest <CatalogueModel>(message));
        }
Example #10
0
        public bool CreateCatalogue(CatalogueModel catalogueModel, out string message)
        {
            try
            {
                //! Do the validation here

                //! TBD --validations

                //! Create or Update the Catalogue
                bool       bNewRecordFlag  = false;
                TCatalogue catalogueEntity = null;
                if (catalogueModel.ItemId == 0) //! New Item
                {
                    catalogueEntity = new TCatalogue();
                    bNewRecordFlag  = true;
                }
                else
                {
                    catalogueEntity = _catalogueRepository.Get(catalogueModel.ItemId);
                    if (catalogueEntity == null)
                    {
                        message = "No Catalogue is found for update! Please enter a valid catalogue id";
                        return(false);
                    }
                }
                catalogueEntity.Companyid = catalogueModel.CompanyId;
                catalogueEntity.Itemdesc  = catalogueModel.Itemdesc;
                catalogueEntity.Itemname  = catalogueModel.Itemname;
                catalogueEntity.Itempic   = catalogueModel.Itempic;
                catalogueEntity.Itemprice = catalogueModel.Itemprice;
                catalogueEntity.Isactive  = true;
                if (bNewRecordFlag)
                {
                    _catalogueRepository.Insert(catalogueEntity);
                    message = "Catalogue created successfully";
                }
                else
                {
                    _catalogueRepository.Update(catalogueEntity);
                    message = "Catalogue updated successfully";
                }
            }
            catch (Exception ex)
            {
                //! TBD Need to log the exception.
                message = "Error occured in Catalogue transaction " + ex.Message; //! Need to remove ex.Message
                return(false);
            }
            return(true);
        }
Example #11
0
        void ucMenuList_Click(object sender, EventArgs e)
        {
            UCMenuList     ucProduct = (UCMenuList)sender;
            CatalogueModel tag       = (CatalogueModel)(ucProduct.Tag);

            foreach (Control ctr in flpMenuList.Controls)
            {
                if (ctr.BackColor == Color.FromArgb(0, 153, 51))
                {
                    ctr.BackColor = Color.FromArgb(255, 255, 255);
                    ctr.ForeColor = Color.FromArgb(51, 51, 51);
                }
            }
            ucProduct.BackColor = Color.FromArgb(0, 153, 51);
            ucProduct.ForeColor = Color.FromArgb(255, 255, 255);
            addMenuListDetail(tag);
        }
Example #12
0
        void ucMenuList_btnSave_Click(object sender, EventArgs e)
        {
            Button         catalogue = (Button)sender;
            CatalogueModel tag       = (CatalogueModel)(catalogue.Tag);

            var ucMenu = (UCMenu)pnDetail.Controls[0];

            if (tag == null)
            {
                tag = new CatalogueModel();
            }

            tag.CatalogueName = ucMenu.txtMenuName.Text;
            tag.Color         = ucMenu.cbColor.Text ?? "";

            if (tag.CatalogueName != "")
            {
                var result  = CatalogeService.SavaDataCatalogue(tag);
                var message = "";
                if (result == 1)
                {
                    addMenuList("Menu List", 1);
                    message = "Save data menu successful";
                }
                else
                {
                    if (result == -1)
                    {
                        message = "Menu name already exists. Please change menu name";
                    }
                    else
                    {
                        message = "Save data menu fail";
                    }
                }
                frmMessager frm = new frmMessager("Messager", message);
                frmOpacity.ShowDialog(this, frm);
            }
            else
            {
                frmMessager frm = new frmMessager("Messager", "Menu name isn't empty.");
                frmOpacity.ShowDialog(this, frm);
            }
        }
Example #13
0
        private void addMenuListDetail(CatalogueModel cata)
        {
            //pnDetail.Controls.Clear();


            if (cata.CatalogueID > 0)
            {
                UCMenu ucMenu = new UCMenu();
                if (pnDetail.Controls.Count > 0)
                {
                    ucMenu = (UCMenu)pnDetail.Controls[0];
                }
                else
                {
                    ucMenu.Dock = DockStyle.Fill;
                    pnDetail.Controls.Add(ucMenu);
                }
                ucMenu.TilteMenu.Text   = cata.CatalogueName;
                ucMenu.txtMenuName.Text = cata.CatalogueName;

                ucMenu.flpIncludesGroup.Controls.Clear();
                ucMenu.addUcMenuGroup(cata.CatalogueID, 1);


                ucMenu.btnSave.Tag    = cata;
                ucMenu.btnSave.Click += ucMenuList_btnSave_Click;

                ucMenu.btnRemove.Tag    = cata;
                ucMenu.btnRemove.Click += ucMenuList_btnRemove_Click;


                ucMenu = (UCMenu)pnDetail.Controls[0];
                ucMenu.cbColor.SelectedItem = cata.Color;
            }
            else
            {
                pnDetail.Controls.Clear();
            }
        }