public async Task <ApiResult <CreateTestCommand> > GetTestByIdAsync(long id)
        {
            try
            {
                if (_unit.Context.Tblusersubmitedanswer.Where(t => t.TestId == id).Any())
                {
                    return(new ApiResult <CreateTestCommand>(new ApiResultCode(ApiResultType.Error, messageText: "Exist edit will not delete from record. user have already tacken test.")));
                }

                var result = await _unit.GetRepository <Tbltest>().GetByID(id);

                if (result.HasSuccess)
                {
                    var testview = new CreateTestCommand();
                    testview.Id           = result.UserObject.Id;
                    testview.CatetoryId   = result.UserObject.CategoryId;
                    testview.Name         = result.UserObject.Name;
                    testview.Description  = result.UserObject.Description;
                    testview.NoOfQuestion = result.UserObject.NoOfQuestion.HasValue ? result.UserObject.NoOfQuestion.Value : 0;
                    return(new ApiResult <CreateTestCommand>(new ApiResultCode(ApiResultType.Success), testview));
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
                return(new ApiResult <CreateTestCommand>(new ApiResultCode(ApiResultType.Error, messageText: "Error while geting data")));
            }
            return(new ApiResult <CreateTestCommand>(new ApiResultCode(ApiResultType.Error, messageText: "no data found")));
        }
Example #2
0
        public async Task <ApiResult <CreateQuestionCommand> > GetQuestionOptionByIdAsync(GetQuestionOptionByIdQuery filter)
        {
            try
            {
                var questionqultion = await _unit.Context.Tblquestion.Include(t => t.Category).Include(t => t.Tblquestionoptions).Where(p => p.Id == filter.Filter.QuestionId && p.Status == 1).FirstOrDefaultAsync();

                var result = new CreateQuestionCommand
                {
                    Id         = questionqultion.Id,
                    Name       = questionqultion.Name,
                    NoOfOption = questionqultion.NoOfOptions.HasValue ? questionqultion.NoOfOptions.Value : Convert.ToInt16(0),
                    CategoryId = questionqultion.CategoryId.Value,
                    DurationId = questionqultion.QuestionDuration.Value,
                    Options    = questionqultion.Tblquestionoptions.Select(x => new CreateOptionCommand
                    {
                        Id        = x.Id,
                        Name      = x.Name,
                        IsMatched = x.IsMatched == 1 ? true : false
                    }).ToList()
                };
                return(new ApiResult <CreateQuestionCommand>(new ApiResultCode(ApiResultType.Success), result));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
                return(new ApiResult <CreateQuestionCommand>(new ApiResultCode(ApiResultType.Error, messageText: "Error while geting data")));
            }
        }
        public async Task <ApiResult <IEnumerable <UserTestMappingResponseModel> > > GetAllTestUser(GetAllTestUserQuery request)
        {
            try
            {
                List <UserTestMappingResponseModel> result = new List <UserTestMappingResponseModel>();
                var query = await _unit.Context.EmployeeDataModel.FromSqlRaw("WITH user_CTE AS (SELECT tsr.Id AS Id, CONCAT(r.FirstName,' ',IFNULL(r.MiddleName,''),' ',IFNULL(r.LastName,'')) AS FullName,r.Id AS UserId FROM tbluser r INNER JOIN `tbltestuserright` tsr ON r.Id=tsr.UserId INNER JOIN `tbltest` tt ON tt.Id = tsr.TestId WHERE tsr.TestId={0} AND tsr.Status=1)SELECT cte.Id AS TestId,CONCAT(u.FirstName,' ',IFNULL(u.MiddleName,''),' ',IFNULL(u.LastName,'')) AS FullName,u.Id AS UserId FROM tbluser u LEFT JOIN user_CTE cte ON u.Id=cte.userId WHERE u.UserTypeId=3 && u.ClientId={1} ORDER BY u.FirstName", request.Filter.TestId, request.CurrentCientId).ToListAsync();

                foreach (var item in query)
                {
                    UserTestMappingResponseModel model = new UserTestMappingResponseModel();
                    model.FullName = item.FullName;
                    model.TestId   = item.TestId;
                    model.UserId   = item.UserId.Value;
                    result.Add(model);
                }
                if (result != null && result.Count > 0)
                {
                    return(new ApiResult <IEnumerable <UserTestMappingResponseModel> >(new ApiResultCode(ApiResultType.Success), result));
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
                return(new ApiResult <IEnumerable <UserTestMappingResponseModel> >(new ApiResultCode(ApiResultType.Error, messageText: "Data not found")));
            }
            return(new ApiResult <IEnumerable <UserTestMappingResponseModel> >(new ApiResultCode(ApiResultType.Error, messageText: "Data not found")));
        }
Example #4
0
        public async Task <ApiResult <IEnumerable <CategoryResponseViewModel> > > GetCategoryWithServiceData(CategoryFilterRequest filter)
        {
            try
            {
                SqlParameter AddressId = new SqlParameter("@Address_Id", System.Data.SqlDbType.Int)
                {
                    Value = filter.AddressId
                };
                var storeIdTable = _context.ExecuteStoreProcedure("Usp_GetStoreId", AddressId);

                var result = await(_context.TblCategoryMaster.Join(_context.TblServiceMaster, cat => cat.Id, ser => ser.Id, (cat, ser) => new { cat, ser })
                                   .Select(c => new CategoryResponseViewModel
                {
                    Name       = c.cat.CategoryName,
                    CategoryId = c.cat.Id,
                    ServiceId  = c.ser.Id,
                    IconUrl    = c.cat.Image
                }).ToListAsync());
                return(result == null
                    ? new ApiResult <IEnumerable <CategoryResponseViewModel> >(new ApiResultCode(ApiResultType.Error, 1, "No data in given request"))
                    : new ApiResult <IEnumerable <CategoryResponseViewModel> >(new ApiResultCode(ApiResultType.Success), result));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.BusinessTier, ex);
                return(new ApiResult <IEnumerable <CategoryResponseViewModel> >(new ApiResultCode(ApiResultType.ExceptionDuringOpration, 3, "Please contact system administrator")));
            }
        }
        public async Task <ApiResult <bool> > DeleteAddress(int?userID, int addressId)
        {
            try
            {
                SqlParameter CustomerId = new SqlParameter("@Address_Id", System.Data.SqlDbType.Int)
                {
                    Value = userID.HasValue ? userID.Value : (object)DBNull.Value
                };
                SqlParameter AddressId = new SqlParameter("@Customer_Id", System.Data.SqlDbType.Int)
                {
                    Value = addressId
                };
                var result = await _context.Database.ExecuteSqlCommandAsync("[usp_DeleteAddress] {0},{1}", AddressId, CustomerId);

                if (result > 0)
                {
                    return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), true));
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.ExceptionDuringOpration), false));
            }
            return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Error), false));
        }
        public async Task <ApiResult <CartCountResponseViewModel> > CartCountAndPrice(int userId)
        {
            CartCountResponseViewModel model = new CartCountResponseViewModel();

            try
            {
                SqlParameter UserId = new SqlParameter("@UserId", System.Data.SqlDbType.Int)
                {
                    Value = userId
                };
                var result = _context.ExecuteStoreProcedure("dbo.usp_GetCartItemCountAndPrice", UserId);
                if (result.Tables[0].Rows.Count > 0)
                {
                    model = (from DataRow dr in result.Tables[0].Rows
                             select new CartCountResponseViewModel()
                    {
                        CartCount = (dr["CartCount"] != DBNull.Value) ? Convert.ToInt32(dr["CartCount"]) : 0,
                        CartPrice = (dr["CartPrice"] != DBNull.Value) ? Convert.ToDecimal(dr["CartPrice"]) : 0,
                        KgCount = (dr["KgCount"] != DBNull.Value) ? Convert.ToDecimal(dr["KgCount"]) : 0,
                        CartId = (dr["CartId"] != DBNull.Value) ? Convert.ToInt32(dr["CartId"]) : 0,
                        IsKg = (dr["IsKg"] != DBNull.Value) ? Convert.ToBoolean(dr["IsKg"]) : false
                    }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
                return(new ApiResult <CartCountResponseViewModel>(new ApiResultCode(ApiResultType.Error, 0, "No data in given request")));
            }
            return(new ApiResult <CartCountResponseViewModel>(new ApiResultCode(ApiResultType.Success), model));
        }
Example #7
0
        public async Task <ApiResult <bool> > UpdateOrderStatus(OrderStatusUpdateRequestModel model, int userId)
        {
            bool isUpdate = false;

            try
            {
                SqlParameter UserId = new SqlParameter("@UserId", System.Data.SqlDbType.Int)
                {
                    Value = userId
                };
                SqlParameter OrderId = new SqlParameter("@OrderId", System.Data.SqlDbType.Int)
                {
                    Value = model.OrderId
                };
                SqlParameter OrderStatusId = new SqlParameter("@OrderStatusId", System.Data.SqlDbType.Int)
                {
                    Value = model.OrderStatusId
                };

                var result = _context.ExecuteStoreProcedure("dbo.[usp_UpdateOrderStatus]", UserId, OrderId, OrderStatusId);

                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), isUpdate));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.ExceptionDuringOpration), isUpdate));
            }
        }
Example #8
0
        public async Task <IActionResult> Handle(AllocateEmployeeCommand request, CancellationToken cancellationToken)
        {
            var _response = new Response();

            try
            {
                var result = await _company.AllocateSuperviser(request);

                if (result.ResultType == Utilities.Results.ApiResultType.Success)
                {
                    _response.Status  = true;
                    _response.Message = result.MessageText;
                    return(_response.ToHttpResponse());
                }
                else
                {
                    _response.Status  = false;
                    _response.Message = result.MessageText;
                    return(_response.ToHttpResponse());
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ProviderLayer, ex);
                _response.Status  = false;
                _response.Message = "Exception";
                return(_response.ToHttpResponse());
            }
        }
        public async Task <IActionResult> Handle(DeleteTestCommand request, CancellationToken cancellationToken)
        {
            var _response = new Response();

            try
            {
                var result = await _test.DeleteTestAsync(request);

                if (result.ResultType == ApiResultType.Success)
                {
                    _response.Status  = true;
                    _response.Message = result.MessageText;
                }
                else
                {
                    _response.Status  = false;
                    _response.Message = result.MessageText;
                }
                return(_response.ToHttpResponse());
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ProviderLayer, ex);
                _response.Status  = false;
                _response.Message = "Exception";
                return(_response.ToHttpResponse());
            }
        }
        public async Task <ApiResult <IEnumerable <AssignRolesViewModel> > > GetAssignRoles()
        {
            try
            {
                var result = await(from usertb in _context.AspNetUserRoles
                                   join role in _context.AspNetRoles on usertb.RoleId equals role.Id
                                   join user in _context.AspNetUsers on usertb.UserId equals user.Id
                                   select new AssignRolesViewModel()
                {
                    //RoleName = role.ne,
                    //RoleId = usertb.RoleId,
                    //UserName = role.RoleName,
                    //UserId = usertb.UserId,
                    //UserRolesId = usertb.UserRolesId
                }).ToListAsync();

                return(result == null
                            ? new ApiResult <IEnumerable <AssignRolesViewModel> >(new ApiResultCode(ApiResultType.Error, 1, "No data in given request"))
                            : new ApiResult <IEnumerable <AssignRolesViewModel> >(new ApiResultCode(ApiResultType.Success), result));
            }
            catch (Exception ex) {
                ErrorTrace.Logger(LogArea.BusinessTier, ex);
                return(new ApiResult <IEnumerable <AssignRolesViewModel> >(new ApiResultCode(ApiResultType.ExceptionDuringOpration, 3, "Please contact system administrator")));
            }
        }
        public async Task <ApiResult <IEnumerable <ItemViewModel> > > GetALLltem()
        {
            try
            {
                var result = await(from itm in _context.TblItemMaster
                                   join subcat in _context.TblSubServiceMaster on itm.Id equals subcat.Id
                                   join cat in _context.TblCategoryMaster on subcat.Id equals cat.Id
                                   join ser in _context.TblServiceMaster on cat.Id equals ser.Id
                                   select new ItemViewModel
                {
                    Name            = itm.ItemName,
                    ServiceId       = ser.Id,
                    CategoryId      = cat.Id,
                    SubcategoryId   = itm.Id,
                    ItemId          = itm.Id,
                    Price           = Convert.ToDecimal(itm.Id),
                    ServiceName     = ser.ServiceName,
                    CategoryName    = cat.CategoryName,
                    SubcategoryName = subcat.SubServiceName
                }
                                   ).ToListAsync();

                return(result == null
                        ? new ApiResult <IEnumerable <ItemViewModel> >(new ApiResultCode(ApiResultType.Error, 1, "No data in given request"))
                        : new ApiResult <IEnumerable <ItemViewModel> >(new ApiResultCode(ApiResultType.Success), result));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.BusinessTier, ex);
                return(new ApiResult <IEnumerable <ItemViewModel> >(new ApiResultCode(ApiResultType.ExceptionDuringOpration, 3, "Please contact system administrator")));
            }
        }
        public async Task <IActionResult> GetServiceCart([FromQuery] int addressId)
        {
            int?userId    = 0;
            var userStrId = this.User.FindFirstValue(ClaimTypes.Name);

            if (!string.IsNullOrWhiteSpace(userStrId))
            {
                userId = Convert.ToInt32(userStrId);
            }

            var response = new SingleResponse <CartPriceDetail>();

            try
            {
                response.Data   = (await _unit.ICart.GetCartDetail(userId.Value, addressId)).UserObject;
                response.Status = true;
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = "There was an internal error, please contact to technical support.";
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
            }
            return(response.ToHttpResponse());
        }
        public async Task <ApiResult <IList <TestsQueryModel> > > GetTestAsync(GetTestByCategoryId filter)
        {
            try
            {
                if (filter.CurrentRoleId != 2)
                {
                    return(new ApiResult <IList <TestsQueryModel> >(new ApiResultCode(ApiResultType.Error, messageText: "You have no access to get this data.")));
                }

                var result = await _unit.GetRepository <Tbltest>().GetSelectedDataAsync(t => (filter.Filter.CategoryId.HasValue ? t.CategoryId == filter.Filter.CategoryId : true) && t.ClientId == filter.CurrentCientId && t.Status == 1, s => new TestsQueryModel
                {
                    Id   = s.Id,
                    Name = s.Name
                });

                if (result != null && result.HasSuccess)
                {
                    return(new ApiResult <IList <TestsQueryModel> >(new ApiResultCode(ApiResultType.Success), result.UserObject.ToList()));
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
                return(new ApiResult <IList <TestsQueryModel> >(new ApiResultCode(ApiResultType.Error, messageText: "Error while geting data")));
            }
            return(new ApiResult <IList <TestsQueryModel> >(new ApiResultCode(ApiResultType.Error, messageText: "no data found")));
        }
        public async Task <IActionResult> GetServiceCartcount()
        {
            int?userId    = 0;
            var userStrId = this.User.FindFirstValue(ClaimTypes.Name);

            if (!string.IsNullOrWhiteSpace(userStrId))
            {
                userId = Convert.ToInt32(userStrId);
            }

            var response = new SingleResponse <CartCountResponseViewModel>();

            try
            {
                var dataResult = (await _unit.ICart.CartCountAndPrice(userId: userId.Value));
                response.Data    = dataResult.HasSuccess ? dataResult.UserObject : null;
                response.Message = "Cart added";
                response.Status  = true;
                return(response.ToHttpResponse());
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = "There was an internal error, please contact to technical support.";
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
            }
            return(response.ToHttpResponse());
        }
Example #15
0
        public async Task <ApiResult <UserClameResponse> > AuthenticateUsers(LoginCommand request)
        {
            UserClameResponse userobj = null;

            try
            {
                userobj = await _unit.Context.Tbluser.Where(t => (t.Email == request.UserName || t.PhoneNumber == request.UserName) && t.PasswordHash == request.Password && t.IsApproved == 1)
                          .Select(t => new UserClameResponse
                {
                    UserId     = t.Id,
                    Email      = t.Email,
                    Phone      = t.PhoneNumber,
                    RoleId     = t.Tbluserrolemapping.Where(p => p.UserId == t.Id).Select(t => t.RoleId).FirstOrDefault(),
                    Role       = t.Tbluserrolemapping.Where(p => p.UserId == t.Id).Select(t => t.Role.Name).FirstOrDefault(),
                    UserName   = t.NormalizedUserName,
                    UserTypeId = t.UserType.Id,
                    UserType   = t.UserType.Name,
                    ClinetId   = t.Client.Id,
                    ClinetName = t.Client.Name
                }).FirstOrDefaultAsync();

                return(new ApiResult <UserClameResponse>(new ApiResultCode(ApiResultType.Success), userobj));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
                return(new ApiResult <UserClameResponse>(new ApiResultCode(ApiResultType.Error, messageText: "Error during Update"), userobj));
            }
        }
Example #16
0
        public ApiResult <bool> IsOrderRefExist(string invoiceNo, string pgType)
        {
            SqlParameter InvoiceNo = new SqlParameter("@InvoiceNo", System.Data.SqlDbType.VarChar)
            {
                Value = invoiceNo
            };
            SqlParameter PgType = new SqlParameter("@pgType", System.Data.SqlDbType.VarChar)
            {
                Value = pgType
            };

            try
            {
                bool isExist = false;
                var  Data    = _context.ExecuteStoreProcedure("[usp_GetOrderRefExist]", InvoiceNo, PgType);
                if (Data != null && Data.Tables.Count > 0 && Data.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow row in Data.Tables[0].Rows)
                    {
                        isExist = (row["IsExist"] != DBNull.Value) ? Convert.ToBoolean(row["IsExist"]) : false;
                    }
                }
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), isExist));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.ExceptionDuringOpration, 3, "Please contact system administrator")));
            }
        }
        public async Task <ApiResult <IEnumerable <StoreResponseViewModel> > > GetStoreByAddress(int addressId)
        {
            List <StoreResponseViewModel> listitems = new List <StoreResponseViewModel>();

            try
            {
                SqlParameter AddressId = new SqlParameter("@Address_Id", System.Data.SqlDbType.Int)
                {
                    Value = addressId
                };
                var ietms = _context.ExecuteStoreProcedure("[Usp_GetStore]", AddressId);

                if (ietms.Tables[0].Rows.Count > 0)
                {
                    listitems = (from DataRow dr in ietms.Tables[0].Rows
                                 select new StoreResponseViewModel()
                    {
                        StoreId = (dr["StoreId"] != DBNull.Value) ? Convert.ToInt32(dr["StoreId"]) : 0,
                        StoreName = (dr["StoreName"] != DBNull.Value) ? Convert.ToString(dr["StoreName"]) : string.Empty,
                        FullAddress = (dr["FullAddress"] != DBNull.Value) ? Convert.ToString(dr["FullAddress"]) : string.Empty
                    }).ToList();
                }
                return(listitems.Count < 0
                            ? new ApiResult <IEnumerable <StoreResponseViewModel> >(new ApiResultCode(ApiResultType.Error, 1, "No data in given request"))
                            : new ApiResult <IEnumerable <StoreResponseViewModel> >(new ApiResultCode(ApiResultType.Success), listitems));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.BusinessTier, ex);
                return(new ApiResult <IEnumerable <StoreResponseViewModel> >(new ApiResultCode(ApiResultType.ExceptionDuringOpration, 3, "Please contact system administrator")));
            }
        }
        public async Task <ApiResult <bool> > UpdateUserAddress(UserAddressRequestViewModel userAddress, int userId)
        {
            try
            {
                SqlParameter AddressId = new SqlParameter("@AddressId", System.Data.SqlDbType.Int)
                {
                    Value = userAddress.AddressId.HasValue ? userAddress.AddressId.Value : (object)DBNull.Value
                };
                SqlParameter Userid = new SqlParameter("@Userid", System.Data.SqlDbType.Int)
                {
                    Value = userId > 0 ? userId : (object)DBNull.Value
                };
                SqlParameter Address2 = new SqlParameter("@Address2", System.Data.SqlDbType.VarChar)
                {
                    Value = userAddress.Address2
                };
                SqlParameter LandMark = new SqlParameter("@LandMark", System.Data.SqlDbType.VarChar)
                {
                    Value = userAddress.LandMark ?? (object)DBNull.Value
                };
                int result = await _context.Database.ExecuteSqlCommandAsync("usp_UpdateUserAddress {0},{1},{2},{3}", AddressId, Userid, Address2, LandMark);

                ///  if (result >0)
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), true));

                // return new ApiResult<bool>(new ApiResultCode(ApiResultType.Success), true);
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Error), false));
            }
        }
Example #19
0
        public async Task <IActionResult> Handle(LOIDocumentUploadCommand request, CancellationToken cancellationToken)
        {
            var _response = new SingleResponse <UplodLoiDocFileResponse>();

            if (request.LoiDocFile != null)
            {
                string strDirectory = "\\LOIDocumnetUpload" + "\\" + Regex.Replace(request.FranchiseeId.ToString(), @"\s+", "");

                Tbluserdoument documentdata = new Tbluserdoument();
                var            fileResult   = WriteFile(request.LoiDocFile, strDirectory, "").Result;

                if (request.DocumentId > 0)
                {
                    documentdata.Id = request.DocumentId;
                }

                if (fileResult.HasSuccess)
                {
                    documentdata.DocImagePath = fileResult.UserObject.ImagePath;
                }

                documentdata.UserId         = request.FranchiseeId;
                documentdata.InsertedBy     = request.CurrentUserId;
                documentdata.DocumentTypeId = 6;
                documentdata.UserTypeId     = request.CurrentUserTypeId;
                documentdata.Remark         = request.LoiDocFile.FileName;
                documentdata.InsertDate     = DateTime.Now;
                documentdata.LastUpdateDate = DateTime.Now;
                documentdata.Status         = 1;
                try
                {
                    var result = await _account.FranchiseeLoiUpload(documentdata);

                    if (result.HasSuccess)
                    {
                        _response.Status  = true;
                        _response.Message = result.ResultCode.MessageText;
                        _response.Data    = result.UserObject;
                        return(_response.ToHttpResponse());
                    }
                    else
                    {
                        _response.Status  = false;
                        _response.Message = result.ResultCode.MessageText;
                        return(_response.ToHttpResponse());
                    }
                }
                catch (Exception ex)
                {
                    ErrorTrace.Logger(LogArea.ProviderLayer, ex);
                    _response.Status  = false;
                    _response.Message = "Exception";
                }
                return(_response.ToHttpResponse());
            }
            _response.Status  = false;
            _response.Message = "Please upload file";
            return(_response.ToHttpResponse());
        }
        public async Task <ApiResult <bool> > AddToCartAsync(AddCartRequestViewModel customerAddToCart, int userId)
        {
            bool iSFromDiffrentService = false;

            try
            {
                SqlParameter CartId = new SqlParameter("@CartId", System.Data.SqlDbType.Int)
                {
                    Value = customerAddToCart.CartId.HasValue ? customerAddToCart.CartId.Value : 0
                };
                SqlParameter StoreId = new SqlParameter("@StoreId", System.Data.SqlDbType.Int)
                {
                    Value = customerAddToCart.StoreId
                };
                SqlParameter ServiceId = new SqlParameter("@ServiceId", System.Data.SqlDbType.Int)
                {
                    Value = customerAddToCart.ServiceId
                };
                SqlParameter StoreItemId = new SqlParameter("@StoreItemId", System.Data.SqlDbType.Int)
                {
                    Value = customerAddToCart.StoreItemId
                };
                SqlParameter IsCartRemoved = new SqlParameter("@IsCartRemoved", System.Data.SqlDbType.Bit)
                {
                    Value = customerAddToCart.IsCartRemoved
                };
                SqlParameter AddressId = new SqlParameter("@AddressId", System.Data.SqlDbType.Int)
                {
                    Value = customerAddToCart.AddressId
                };
                SqlParameter UserId = new SqlParameter("@UserId", System.Data.SqlDbType.Int)
                {
                    Value = userId
                };
                SqlParameter Quantity = new SqlParameter("@Quantity", System.Data.SqlDbType.Int)
                {
                    Value = customerAddToCart.Quantity ?? (object)DBNull.Value
                };
                var result = _context.ExecuteStoreProcedure("dbo.usp_AddCart", CartId, StoreId, ServiceId, StoreItemId, Quantity, IsCartRemoved, AddressId, UserId);
                if (result.Tables.Count > 0 && result.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow row in result.Tables[0].Rows)
                    {
                        if (((row["ErrorMessage"] != DBNull.Value) ? Convert.ToString(row["ErrorMessage"]) : string.Empty) == "1")
                        {
                            iSFromDiffrentService = true;
                        }
                    }
                }
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), iSFromDiffrentService));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
            }
            return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), false));
        }
        public async Task <ApiResult <bool> > SaveUserAddress(UserAddressRequestViewModel userAddress, int userId)
        {
            try
            {
                userAddress.IsDefaultDeliveryLocation = true;
                SqlParameter AddressId = new SqlParameter("@AddressId", System.Data.SqlDbType.Int)
                {
                    Value = userAddress.AddressId.HasValue ? userAddress.AddressId.Value : (object)DBNull.Value
                };
                SqlParameter Userid = new SqlParameter("@Userid", System.Data.SqlDbType.Int)
                {
                    Value = userId > 0 ? userId : (object)DBNull.Value
                };
                SqlParameter Longitude = new SqlParameter("@Longitude", System.Data.SqlDbType.Decimal)
                {
                    Value = userAddress.Longitude
                };
                SqlParameter Latitude = new SqlParameter("@Latitude", System.Data.SqlDbType.Decimal)
                {
                    Value = userAddress.Latitude
                };
                SqlParameter Address1 = new SqlParameter("@Address1", System.Data.SqlDbType.VarChar)
                {
                    Value = userAddress.Address1 ?? (object)DBNull.Value
                };
                SqlParameter Address2 = new SqlParameter("@Address2", System.Data.SqlDbType.VarChar)
                {
                    Value = userAddress.Address2 ?? (object)DBNull.Value
                };
                SqlParameter LandMark = new SqlParameter("@LandMark", System.Data.SqlDbType.VarChar)
                {
                    Value = userAddress.LandMark ?? (object)DBNull.Value
                };
                SqlParameter AddressTypeId = new SqlParameter("@AddressTypeId", System.Data.SqlDbType.Int)
                {
                    Value = userAddress.AddressTypeId
                };
                SqlParameter IsDefaultDeliveryLocation = new SqlParameter("@IsDefaultDeliveryLocation", System.Data.SqlDbType.Bit)
                {
                    Value = userAddress.IsDefaultDeliveryLocation
                };
                int result = await _context.Database.ExecuteSqlCommandAsync("usp_SaveUserAddress {0},{1},{2},{3},{4},{5},{6},{7},{8}", AddressId, Userid, Longitude, Latitude, Address1, Address2, LandMark, AddressTypeId, IsDefaultDeliveryLocation);

                if (result > 0)
                {
                    return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), true));
                }
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
            }
            return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), false));
        }
Example #22
0
 public virtual ApiResultCode UpdateAll(IEnumerable <TEntity> entities)
 {
     try
     {
         _context.Set <TEntity>().AddRange(entities);
         return(new ApiResultCode(ApiResultType.Success, 1, "Deleted successfully"));
     }
     catch (Exception ex)
     {
         ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
         return(new ApiResultCode(ApiResultType.Error, 3, "Please contact system administrator"));
     }
 }
 public virtual ApiResultCode UpdateAll(IEnumerable <TEntity> entities)
 {
     try
     {
         Context.Set <TEntity>().AttachRange(entities);
         return(new ApiResultCode(ApiResultType.Success, 1, "Items updated successfully"));
     }
     catch (Exception ex)
     {
         ErrorTrace.Logger(LogArea.BusinessTier, ex);
         return(new ApiResultCode(ApiResultType.ExceptionDuringOpration, 3, "Please contact system administrator"));
     }
 }
Example #24
0
 public ApiResultCode SaveChanges()
 {
     try
     {
         Context.SaveChanges();
         return(new ApiResultCode(ApiResultType.Success, 1, "Save successfully"));
     }
     catch (Exception ex)
     {
         ErrorTrace.Logger(LogArea.DataAccessLayer, ex);
         return(new ApiResultCode(ApiResultType.Error, 3, "Exception during saveing"));
     }
 }
Example #25
0
        public async Task <IActionResult> Post([FromForm] UserAddressRequestViewModel value)
        {
            int?userId    = 0;
            var struserId = this.User.FindFirstValue(ClaimTypes.Name);

            if (!string.IsNullOrWhiteSpace(struserId))
            {
                userId = Convert.ToInt32(struserId);
            }


            var response = new ListResponse <UserAddressResponseViewModel>();

            try
            {
                var result = new ApiResult <bool>();
                if (value.AddressId != null && value.AddressId > 0)
                {
                    result = await _unit.IUserAddress.UpdateUserAddress(userAddress : value, userId : userId.Value);

                    response.Data    = (await _unit.IUserAddress.UserAddress(userId: userId.Value, addressId: value.AddressId)).UserObject;
                    response.Message = "Success";
                    response.Status  = true;
                    return(response.ToHttpResponse());
                }
                else
                {
                    result = await _unit.IUserAddress.SaveUserAddress(userAddress : value, userId : userId.Value);

                    if (result.HasSuccess)
                    {
                        response.Data    = null;
                        response.Message = "Success";
                        response.Status  = true;
                    }
                    else
                    {
                        response.Data    = null;
                        response.Message = "Error";
                        response.Status  = false;
                    }
                }
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = "There was an internal error, please contact to technical support.";
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
            }
            return(response.ToHttpResponse());
        }
Example #26
0
        public async Task <ApiResult <TestResultQueryModel> > GetTestResultAsync(GetTestResultByTestIdQuery filter)
        {
            try
            {
                TestResultQueryModel modeltest = null;
                var temp = _unit.Context.Tbltestuserright.Where(p => p.UserId == filter.CurrentUserId && p.TestId == filter.Filter.TestId && p.Status == 1)
                           .Include(t => t.User).Include(t => t.Test).ThenInclude(t => t.Tblusersubmitedanswer).ThenInclude(t => t.Question).
                           ThenInclude(t => t.Tblquestionoptions).FirstOrDefault();

                var testresult = await _unit.Context.Tbltest.Where(p => p.Id == filter.Filter.TestId).
                                 Include(t => t.Tblusersubmitedanswer).ThenInclude(t => t.Question).
                                 ThenInclude(t => t.Tblquestionoptions).Include(t => t.Tbltestuserright).ThenInclude(t => t.User).FirstOrDefaultAsync();

                if (testresult != null)
                {
                    modeltest                     = new TestResultQueryModel();
                    modeltest.UserId              = filter.CurrentUserId.Value;
                    modeltest.UserName            = testresult.Tblusersubmitedanswer.Where(t => t.UserId == filter.CurrentUserId).Select(t => (t.User.FirstName + " " + t.User.MiddleName + " " + t.User.LastName)).FirstOrDefault();
                    modeltest.TestId              = testresult.Id;
                    modeltest.TestName            = testresult.Name;
                    modeltest.TotalQuestion       = testresult.NoOfQuestion.HasValue ? testresult.NoOfQuestion.Value : 0;
                    modeltest.TotalAtemptQuestion = testresult.Tblusersubmitedanswer.Where(t => t.UserId == filter.CurrentUserId.Value && t.IsMatched.HasValue).GroupBy(g => g.QuestionId).Count();
                    modeltest.TotalWorngAnswer    = testresult.Tblusersubmitedanswer.Where(t => (t.UserId == filter.CurrentUserId.Value && t.IsMatched.HasValue) && t.IsMatched != t.Option.IsMatched).Count();
                    modeltest.TotalCorrenctAnswer = testresult.Tblusersubmitedanswer.Where(t => (t.UserId == filter.CurrentUserId.Value && t.IsMatched.HasValue) && t.IsMatched == t.Option.IsMatched).Count();
                    modeltest.Questions           = testresult.Tblusersubmitedanswer.Where(t => t.UserId == filter.CurrentUserId).GroupBy(t => t.QuestionId).Select(q => new TestQuestionQueryModel
                    {
                        Question   = q.FirstOrDefault().Question.Name,
                        QuestionId = q.FirstOrDefault().Question.Id,
                        Options    = q.FirstOrDefault().Question.Tblusersubmitedanswer.Where(t => t.UserId == filter.CurrentUserId && t.QuestionId == q.FirstOrDefault().Question.Id)
                                     .Select(t => new TestQuestionOptionsQueryModel
                        {
                            OptionId  = t.Id,
                            Option    = t.Option.Name,
                            IsSelect  = t.Option.IsMatched,
                            IsCorrect = t.IsMatched
                        }).ToList()
                    }).ToList();
                }
                if (modeltest != null)
                {
                    return(new ApiResult <TestResultQueryModel>(new ApiResultCode(ApiResultType.Success), modeltest));
                }

                return(new ApiResult <TestResultQueryModel>(new ApiResultCode(ApiResultType.Error, messageText: "no data found")));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
                return(new ApiResult <TestResultQueryModel>(new ApiResultCode(ApiResultType.Error, messageText: "Error while geting data")));
            }
        }
Example #27
0
        public ApiResult <string> SaveCustomerPaymentInfo(PaymetIfoRequestViewModel model)
        {
            string deviceType = string.Empty;

            try
            {
                SqlParameter OrderRef = new SqlParameter("@InvoiceNo", System.Data.SqlDbType.VarChar)
                {
                    Value = model.InvoiceNo
                };
                SqlParameter PgRequest = new SqlParameter("@PGRequest", System.Data.SqlDbType.NVarChar)
                {
                    Value = model.PgRequest ?? (object)DBNull.Value
                };
                SqlParameter PgResponse = new SqlParameter("@PGResponse", System.Data.SqlDbType.NVarChar)
                {
                    Value = model.PgResponse ?? (object)DBNull.Value
                };
                SqlParameter ToalPayment = new SqlParameter("@TotalPayment", System.Data.SqlDbType.Decimal)
                {
                    Value = model.TotalPayment.HasValue ? model.TotalPayment.Value : (object)DBNull.Value
                };
                SqlParameter pgType = new SqlParameter("@PG_Type", System.Data.SqlDbType.VarChar)
                {
                    Value = model.PgType ?? (object)DBNull.Value
                };
                SqlParameter PGTransactionId = new SqlParameter("@PGTransactionId", System.Data.SqlDbType.VarChar)
                {
                    Value = model.PGTransactionId ?? (object)DBNull.Value
                };
                SqlParameter Status = new SqlParameter("@Status", System.Data.SqlDbType.VarChar)
                {
                    Value = model.Status ?? (object)DBNull.Value
                };
                var result = _context.ExecuteStoreProcedure("[usp_SavePaymentResponse]", OrderRef, PgRequest, PgResponse, ToalPayment, pgType, PGTransactionId, Status);

                if (result != null && result.Tables.Count > 0 && result.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow row in result.Tables[0].Rows)
                    {
                        deviceType = (row["Message"] != DBNull.Value) ? Convert.ToString(row["Message"]) : string.Empty;
                    }
                }
                return(new ApiResult <string>(new ApiResultCode(ApiResultType.Success), deviceType));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.ApplicationTier, ex);
                return(new ApiResult <string>(new ApiResultCode(ApiResultType.ExceptionDuringOpration), deviceType));
            }
        }
        public async Task <ApiResult <IEnumerable <ItemResponseViewModel> > > GetItemByStore(CategoryItemFilterRequest filterRequest)
        {
            List <ItemResponseViewModel> listitems = new List <ItemResponseViewModel>();

            try
            {
                SqlParameter CategoryId = new SqlParameter("@CategoryId", System.Data.SqlDbType.Int)
                {
                    Value = filterRequest.CategoryId
                };
                SqlParameter StoreId = new SqlParameter("@StoreId", System.Data.SqlDbType.Int)
                {
                    Value = filterRequest.StoreId
                };
                SqlParameter ServiceId = new SqlParameter("@ServiceId", System.Data.SqlDbType.Int)
                {
                    Value = filterRequest.ServiceId
                };
                SqlParameter Userid = new SqlParameter("@Userid", System.Data.SqlDbType.Int)
                {
                    Value = filterRequest.UserId
                };
                var ietms = _context.ExecuteStoreProcedure("[Usp_GetItemByStore]", ServiceId, CategoryId, StoreId, Userid);

                if (ietms.Tables[0].Rows.Count > 0)
                {
                    listitems = (from DataRow dr in ietms.Tables[0].Rows
                                 select new ItemResponseViewModel()
                    {
                        ServiceId = (dr["ServiceId"] != DBNull.Value) ? Convert.ToInt32(dr["ServiceId"]) : 0,
                        StoreId = (dr["StoreId"] != DBNull.Value) ? Convert.ToInt32(dr["StoreId"]) : 0,
                        CategoryId = (dr["CategoryId"] != DBNull.Value) ? Convert.ToInt32(dr["CategoryId"]) : 0,
                        StoreItemId = (dr["StoreItemId"] != DBNull.Value) ? Convert.ToInt32(dr["StoreItemId"]) : 0,
                        Name = (dr["ItemName"] != DBNull.Value) ? Convert.ToString(dr["ItemName"]) : string.Empty,
                        Image = (dr["Image"] != DBNull.Value) ? Convert.ToString(dr["Image"]) : string.Empty,
                        CartId = (dr["CartId"] != DBNull.Value) ? Convert.ToInt32(dr["CartId"]) : 0,
                        Price = (dr["Price"] != DBNull.Value) ? Convert.ToDecimal(dr["Price"]) : 0,
                        Quantity = (dr["CartCount"] != DBNull.Value) ? Convert.ToInt32(dr["CartCount"]) : 0,
                        IsKg = (dr["IsKg"] != DBNull.Value) ? Convert.ToBoolean(dr["IsKg"]) : false,
                    }).ToList();
                }
                return(listitems.Count < 0
                            ? new ApiResult <IEnumerable <ItemResponseViewModel> >(new ApiResultCode(ApiResultType.Error, 1, "No data in given request"))
                            : new ApiResult <IEnumerable <ItemResponseViewModel> >(new ApiResultCode(ApiResultType.Success), listitems));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.BusinessTier, ex);
                return(new ApiResult <IEnumerable <ItemResponseViewModel> >(new ApiResultCode(ApiResultType.ExceptionDuringOpration, 3, "Please contact system administrator")));
            }
        }
Example #29
0
 public virtual ApiResultCode Update(TEntity entity)
 {
     try
     {
         _context.Set <TEntity>().Attach(entity);
         _context.Entry(entity).State = EntityState.Modified;
         return(new ApiResultCode(ApiResultType.Success, 1, "Item updated successfully"));
     }
     catch (Exception ex)
     {
         ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
         return(new ApiResultCode(ApiResultType.Error, 3, "Error during item update"));
     }
 }
        public async Task <ApiResult <bool> > IsTestNameExist(string testname)
        {
            try
            {
                var userobj = await _unit.Context.Tbltest.AnyAsync(t => t.Name == testname);

                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Success), userobj));
            }
            catch (Exception ex)
            {
                ErrorTrace.Logger(LogArea.RepositoryLayer, ex);
                return(new ApiResult <bool>(new ApiResultCode(ApiResultType.Error, messageText: "Invalid Data cannot search!")));
            }
        }