public IGernalResult AddItem(ItemDto s)
        {
            IGernalResult result = new GernalResult();

            try
            {
                TblItem item = new TblItem
                {
                    Name        = s.Name,
                    CategoryId  = s.CatogeryId,
                    Discription = s.Discription,
                    ImageUrl    = s.Image,
                    Price       = s.Price,
                    Quantity    = s.Quantity,
                    SellerId    = Convert.ToInt32(s.SellerId),
                    CreatedDate = DateTime.UtcNow,
                    IsAvailable = true,
                    IsDelete    = false
                };

                _dbContext.Add(item);
                int save = _dbContext.SaveChanges();
                result.Succsefully = save > 0 ? true : false;
                result.Message     = save > 0 ? "Selling Item add Succsefully" : "Selling Item not register";
            }
            catch (Exception ex)
            {
                result.Succsefully = false;
                result.Message     = "Server error";
            }
            return(result);
        }
Beispiel #2
0
        public IGernalResult UserRegistration(UserDto dto)
        {
            IGernalResult result = new GernalResult();

            try
            {
                TblUser User = new TblUser
                {
                    Name        = dto.Name,
                    Address     = dto.Address,
                    Email       = dto.Email,
                    Password    = dto.Password,
                    ImageUrl    = dto.ImageUrl,
                    RoleId      = dto.RoleId,
                    MobileNo    = dto.MobileNo,
                    CreatedDate = DateTime.UtcNow,
                    IsSeller    = dto.RoleId > 1 ? true : false
                };
                string userType = dto.RoleId > 1 ? "Seller" : "User";
                _dbContext.Add(User);
                int save = _dbContext.SaveChanges();
                result.Succsefully = save > 0 ? true : false;
                result.Message     = save > 0 ? userType + " register Succsefully" : userType + "not register";
            }
            catch
            {
                result.Succsefully = false;
                result.Message     = "server error";
            }
            return(result);
        }