Exemplo n.º 1
0
        public UserUI Add(UserUI Entity)
        {
            Entity.Pwd = HelperMethods.Encrypt(Entity.Pwd, true);
            Entity.UT  = UserTypeUI.Admin;
            var condition  = PredicateBuilder.Create <User>(s => s.UserName == Entity.UN || s.Email == Entity.Eml && s.Status == RecordStatus.Active);
            var existsuser = _unitOfWork.UserRepository.GetFilteredList(condition).Item1;

            if (existsuser != null && existsuser.Any())
            {
                return(Entity);
            }

            Entity.PC = "Concept_" + Entity.UN.Substring(0, 2).ToUpper() + Entity.FN.Substring(0, 2).ToUpper() + Entity.Mo.Substring(0, 2);
            //StringBuilder builder = new StringBuilder();
            //builder.Append(RandomNumber(1000, 9999));
            //builder.Append(RandomString(Entity.UN.Substring(0, 2).Count(), true));
            //builder.Append(RandomString(Entity.FN.Substring(0, 2).Count(), false));

            //Entity.PC = builder.ToString();
            var user = Mapper.Map <UserUI, User>(Entity);

            _unitOfWork.UserRepository.Insert(user);
            _unitOfWork.Save();

            if (user != null)
            {
                var userModel = Mapper.Map <User, UserUI>(user);

                return(userModel);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public ShopMasterUI Add(ShopMasterUI Entity, string basePath)
        {
            var Shop = Mapper.Map <ShopMasterUI, ShopMaster>(Entity);

            _unitOfWork.ShopMastersRepository.Insert(Shop);
            _unitOfWork.Save();
            if (Shop != null)
            {
                var Shopui = Mapper.Map <ShopMaster, ShopMasterUI>(Shop);

                return(Shopui);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        public CategorysMasterUI Add(CategorysMasterUI Entity)
        {
            var building = Mapper.Map <CategorysMasterUI, CategorysMaster>(Entity);

            //building.SiteMaster = _unitOfWork.SiteMastersRepository.GetByID(Entity.SiteId);
            _unitOfWork.CategorysMasterRepository.Insert(building);
            _unitOfWork.Save();
            if (building != null)
            {
                var taskModel = Mapper.Map <CategorysMaster, CategorysMasterUI>(building);
                return(taskModel);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public OrderUI Add(OrderUI Entity, long companyid)
        {
            var Order = Mapper.Map <OrderUI, Order>(Entity);

            Order.OrderDate = DateTime.Now;
            _unitOfWork.OrderRepository.Insert(Order);
            _unitOfWork.Save();
            if (Order != null)
            {
                var taskModel = Mapper.Map <Order, OrderUI>(Order);
                return(taskModel);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Entity"></param>
        /// <param name="basePath"></param>
        /// <param name="companyid"></param>
        /// <returns></returns>
        public ProductMasterUI Add(ProductMasterUI Entity, string basePath, long companyid)
        {
            var condition           = PredicateBuilder.Create <ProductMaster>(s => s.ProductName == Entity.PN && s.Status == RecordStatus.Active);
            var existsProductMaster = _unitOfWork.ProductMastersRepository.GetFilteredList(condition).Item1;

            if (existsProductMaster != null && existsProductMaster.Any())
            {
                return(Entity);
            }

            if (Entity.Image != null)
            {
                //string imgPath = "~/CompanyLogo/" + Entity.PN + ".jpg";

                //  string folderPath = HostingEnvironment.MapPath("~/CompanyLogo/");
                string folderPath = System.Web.HttpContext.Current.Server.MapPath("~/CompanyLogo");
                if (!Directory.Exists(folderPath))
                {
                    //If Directory (Folder) does not exists. Create it.
                    Directory.CreateDirectory(folderPath);
                }
                string FilePathOther = folderPath + "\\" + Entity.PN + ".PNG";
                //HelperMethods.Base64ToImage(Entity.Image).Save(FilePathOther);

                byte[] imageBytes = Convert.FromBase64String(Entity.Image);

                File.WriteAllBytes(FilePathOther, imageBytes);

                Entity.Image = string.Format("{0}{1}{2}", ConfigurationManager.AppSettings["basePath"], ConfigurationManager.AppSettings["CompanyLogoPath"], Entity.PN + ".PNG");
            }
            var ProductMaster = Mapper.Map <ProductMasterUI, ProductMaster>(Entity);

            _unitOfWork.ProductMastersRepository.Insert(ProductMaster);
            _unitOfWork.Save();

            if (ProductMaster != null)
            {
                var ProductMasterModel = Mapper.Map <ProductMaster, ProductMasterUI>(ProductMaster);

                return(ProductMasterModel);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Delete Token by UserId
 /// </summary>
 /// <param name="userId">User id</param>
 /// <returns>returns true if token deleted successfully</returns>
 public bool DeleteByUserId(long userId)
 {
     _unitOfWork.TokensRepository.Delete(a => a.UserId == userId);
     _unitOfWork.Save();
     return(true);
 }