Example #1
0
        public CmnItemColor GetColorsById(vmCmnParameters objcmnParam)
        {
            GenericFactory_EF_Color = new CmnItemColor_EF();
            CmnItemColor objColors = null;

            try
            {
                var TblColor = GenericFactory_EF_Color.FindBy(m => m.ItemColorID == objcmnParam.id);

                objColors = (from c in TblColor
                             where c.ItemColorID == objcmnParam.id
                             orderby c.ItemColorID descending
                             select new
                {
                    ItemColorID = c.ItemColorID,
                    ColorName = c.ColorName,
                    ColorCode = c.ColorCode,
                    CustomCode = c.CustomCode
                }).Select(x => new CmnItemColor
                {
                    ItemColorID = x.ItemColorID,
                    ColorName   = x.ColorName,
                    ColorCode   = x.ColorCode,
                    CustomCode  = x.CustomCode
                }).FirstOrDefault();
            }
            catch (Exception e)
            {
                e.ToString();
            }
            return(objColors);
        }
        public IHttpActionResult GetColorById(object[] data)
        {
            CmnItemColor    objColor    = null;
            vmCmnParameters objcmnParam = JsonConvert.DeserializeObject <vmCmnParameters>(data[0].ToString());

            try
            {
                objColor = objColorService.GetColorsById(objcmnParam);
            }
            catch (Exception e)
            {
                e.ToString();
            }
            return(Json(new
            {
                objColor
            }));
            //return objColor;
        }
Example #3
0
        /// No CompanyID Provided
        /// <summary>
        /// Save Data To Database
        /// <para>Use it when save data through ORM</para>
        /// </summary>
        public string SaveUpdateColors(vmColor model, vmCmnParameters objcmnParam)
        {
            string result = string.Empty;

            using (var transaction = new TransactionScope())
            {
                GenericFactory_EF_Color = new CmnItemColor_EF();
                string CustomNo = string.Empty, CustomCode = string.Empty; long ItemColorID = 0;
                //string strTblName = model.ToString().Substring(model.ToString().LastIndexOf(".") + 1);
                var Master = new CmnItemColor();
                try
                {
                    if (model.ItemColorID > 0)
                    {
                        Master           = GenericFactory_EF_Color.GetAll().Where(x => x.ItemColorID == model.ItemColorID).FirstOrDefault();
                        Master.ColorCode = model.ColorCode;
                        Master.ColorName = model.ColorName;
                        Master.CompanyID = objcmnParam.loggedCompany;
                        Master.UpdateBy  = objcmnParam.loggeduser;
                        Master.UpdateOn  = DateTime.Now;
                        Master.UpdatePc  = HostService.GetIP();
                        CustomCode       = Master.CustomCode;
                    }
                    else
                    {
                        ItemColorID = Convert.ToInt16(GenericFactory_EF_Color.getMaxID("CmnItemColor"));
                        CustomNo    = GenericFactory_EF_Color.getCustomCode(objcmnParam.menuId, DateTime.Now, objcmnParam.loggedCompany, 1, 1); // // 1 for user id and 1 for db id --- work later
                        if (CustomNo == null)
                        {
                            CustomCode = ItemColorID.ToString();
                        }
                        else
                        {
                            CustomCode = CustomNo;
                        }

                        Master = new CmnItemColor
                        {
                            ItemColorID = Convert.ToInt32(ItemColorID),
                            ColorName   = model.ColorName,
                            ColorCode   = model.ColorCode,
                            CustomCode  = CustomCode,

                            StatusID  = 1,
                            CompanyID = objcmnParam.loggedCompany,
                            CreateBy  = objcmnParam.loggeduser,
                            CreateOn  = DateTime.Now,
                            CreatePc  = HostService.GetIP()
                        };
                    }

                    if (model.ItemColorID > 0)
                    {
                        GenericFactory_EF_Color.Update(Master);
                        GenericFactory_EF_Color.Save();
                    }
                    else
                    {
                        GenericFactory_EF_Color.Insert(Master);
                        GenericFactory_EF_Color.Save();
                        GenericFactory_EF_Color.updateMaxID("CmnItemColor", Convert.ToInt64(ItemColorID));
                        GenericFactory_EF_Color.updateCustomCode(objcmnParam.menuId, DateTime.Now, objcmnParam.loggedCompany, 1, 1);
                    }
                    transaction.Complete();
                    result = CustomCode;
                }
                catch (Exception e)
                {
                    e.ToString();
                    result = "";
                }
            }
            return(result);
        }