public async Task <ActionResult <ResponseWithData <SignIn.response> > > SignIn(SignIn.request request)
        {
            var response = new ResponseWithData <SignIn.response>();
            var user     = await _userManager.FindByEmailAsync(request.Email);

            if (user == null)
            {
                return(BadRequest("Email Not Exists"));
            }
            var result = await _signInManager.PasswordSignInAsync(user, request.Password, false, true);

            if (result.Succeeded == false)
            {
                return(BadRequest("Email And Password Doesnot Match"));
            }
            response.Data       = new SignIn.response();
            response.Data.Token = generateToken(new List <Claim>()
            {
                new Claim(ClaimTypes.Name, user.Email),
                new Claim(ClaimTypes.Role, "student")
            });


            return(Ok(response));
        }
        public async Task <ActionResult <ResponseWithData <SignUp.response> > > SignUp(SignUp.request request)
        {
            var response = new ResponseWithData <SignUp.response>();

            if (await CheckMail(request.Email))
            {
                response.AddError(1);
                return(response);
            }
            var user = new ApplicationUser()
            {
                Email    = request.Email,
                UserName = request.Email
            };
            var result = await _userManager.CreateAsync(user, request.Password);

            if (result.Succeeded == false)
            {
                return(BadRequest("Some thing went wrong"));
            }

            response.Data = new SignUp.response()
            {
                Email    = request.Email,
                Token    = _db.GetToken(),
                Password = request.Password
            };

            return(Ok(response));
        }
Exemple #3
0
        public ActionResult GetProductList()
        {
            ResponseWithData <List <GetProductModel> > _response = new ResponseWithData <List <GetProductModel> >();
            var _getList = _productRepository.GetProductList().Where(x => x.Status == (int)Status.Active && x.IsDeleted == false).ToList();

            return(View(_getList));
        }
Exemple #4
0
        public HttpResponseMessage CreateOrder(OrderModel orderModel)
        {
            ResponseWithData <Order> _response = new ResponseWithData <Order>();

            var model = Mapper.Map <OrderModel, Order>(orderModel);

            model.CreatedDate = DateTime.Now;
            model.Status      = 1;
            model.IsDeleted   = false;
            var Result = _orderRepository.SaveReturnModel(model);

            if (Result != null)
            {
                _response.Type    = "success";
                _response.Message = "Order created successfully";
                _response.data    = Result;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Something went wrong";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
        CheckEmailExists(CheckMail.Request request)
        {
            var response = new ResponseWithData <CheckMail.Response>();

            response.Data        = new CheckMail.Response();
            response.Data.Exists = await CheckMail(request.Email);

            return(Ok(response));
        }
Exemple #6
0
        public ActionResult CreateUser(UsermasterModel usermasterModel)
        {
            ViewBag.Role = _commonRepository.GetUserRoleList().ToList();
            ResponseWithData <Usermaster> _response = new ResponseWithData <Usermaster>();

            if (ModelState.IsValid)
            {
                try
                {
                    using (var client = new HttpClient())
                    {
                        string apiURL = BaseUrl + "api/ApiUser/CreateUser";
                        client.BaseAddress = new Uri(apiURL);
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                        HttpResponseMessage response = client.PostAsJsonAsync(apiURL, usermasterModel).Result;
                        if (response.IsSuccessStatusCode)
                        {
                            _response = (new JavaScriptSerializer()).Deserialize <ResponseWithData <Usermaster> >(response.Content.ReadAsStringAsync().Result);
                            // Return error message
                            if (_response.Type.ToLower() == "error")
                            {
                                ViewBag.Error = _response.Message;
                                return(View(usermasterModel));
                            }
                            ViewBag.UserName = _response.data.UserName;
                            ViewBag.Password = _response.data.Password;
                            ViewBag.Success  = _response.Message;
                            ModelState.Clear();
                        }
                        else
                        {
                            ViewBag.Error = "Error:" + _response.Message;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ViewBag.Error = "Error:" + ex.Message;
                }
            }
            return(View());
        }
Exemple #7
0
        public HttpResponseMessage GetRegisrationDetail(Int64 registerId)
        {
            ResponseWithData <Registration> _response = new ResponseWithData <Registration>();
            var _registrationDetail = _registrationRepository.FindBy(x => x.RegistrationId == registerId).FirstOrDefault();

            if (_registrationDetail != null)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _registrationDetail;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Invalid Credential";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
        public HttpResponseMessage GetProductList()
        {
            ResponseWithData <List <GetProductModel> > _response = new ResponseWithData <List <GetProductModel> >();
            var _getList = _productRepository.GetProductList().Where(x => x.Status == (int)Status.Active && x.IsDeleted == false).ToList();

            if (_getList.Count > 0)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _getList;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "No record found";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #9
0
        public HttpResponseMessage GetDeletedUserList()
        {
            ResponseWithData <List <GetUsermasterModel> > _response = new ResponseWithData <List <GetUsermasterModel> >();
            var getList = _userMaster.GetUserList().Where(x => x.IsDeleted == true).OrderByDescending(x => x.UserId).ToList();

            if (getList.Count > 0)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = getList;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "No record found";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #10
0
        public HttpResponseMessage GetLoginDetail(string userName, string password)
        {
            ResponseWithData <Usermaster> _response = new ResponseWithData <Usermaster>();
            var _userDetail = _userMaster.FindBy(x => x.UserName.Trim().ToLower() == userName.Trim().ToLower() && x.Password == password).FirstOrDefault();

            if (_userDetail != null)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _userDetail;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Invalid Credential";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #11
0
        public HttpResponseMessage GetUserById(Int64 userId)
        {
            ResponseWithData <Usermaster> _response = new ResponseWithData <Usermaster>();
            var _userDetail = _userMaster.FindBy(x => x.UserId == userId).FirstOrDefault();

            if (_userDetail != null)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _userDetail;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Invalid Credential";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #12
0
        public HttpResponseMessage GetSchemeDeailsById(Int64 schemeId)
        {
            ResponseWithData <GetSchemeModel> _response = new ResponseWithData <GetSchemeModel>();
            var _details = _schemeRepository.GetSchemeDetailsById(schemeId).FirstOrDefault();

            if (_details != null)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _details;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "No record found";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #13
0
        public HttpResponseMessage GetSchemeListByDeal(Int64 dealId)
        {
            ResponseWithData <List <GetSchemeModel> > _response = new ResponseWithData <List <GetSchemeModel> >();
            var _getList = _schemeRepository.GetSchemeListByDeal(dealId).ToList();

            if (_getList.Count > 0)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _getList;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "No record found";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
        public HttpResponseMessage GetProductCategoryById(Int64 productCategoryId)
        {
            ResponseWithData <ProductCategory> _response = new ResponseWithData <ProductCategory>();
            var _getDetails = _productCategoryRepository.FindBy(x => x.ProductCategoryId == productCategoryId && x.Status == (int)Status.Active && x.IsDeleted == false).FirstOrDefault();

            if (_getDetails != null)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _getDetails;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Invalid Company";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #15
0
        public HttpResponseMessage GetOrderDetails(Int64 OrderId)
        {
            ResponseWithData <Order> _response = new ResponseWithData <Order>();
            var _getDetails = _orderRepository.FindBy(x => x.OrderId == OrderId && x.Status == (int)Status.Active && x.IsDeleted == false).FirstOrDefault();

            if (_getDetails != null)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = _getDetails;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "Invalid Order";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #16
0
        public HttpResponseMessage GetStateList(int CountryId)
        {
            ResponseWithData <List <State> > _response = new ResponseWithData <List <State> >();
            var list = _common.GetState(CountryId).ToList();

            if (list.Count > 0)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = list;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "No Record Found";
                _response.data    = list;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }
Exemple #17
0
        public HttpResponseMessage CreateUser(UsermasterModel usermasterModel)
        {
            ResponseWithData <Usermaster> _response = new ResponseWithData <Usermaster>();
            var _getUser = _userMaster.FindBy(x => x.Phone == usermasterModel.Phone.Trim() || x.Email.Trim().ToLower() == usermasterModel.Email.Trim().ToLower()).FirstOrDefault();

            if (_getUser != null)
            {
                _response.Type    = "error";
                _response.Message = "User already Exist";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }

            var model = Mapper.Map <UsermasterModel, Usermaster>(usermasterModel);

            string[] arrName = model.Email.Split('@');
            model.UserName  = model.Email.Trim();
            model.Password  = arrName[0] + "@123";
            model.Status    = 0;
            model.IsDeleted = false;
            var response = _userMaster.CreateUser(model);

            if (response != null)
            {
                _response.Type    = "success";
                _response.Message = "success";
                _response.data    = response;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
            else
            {
                _response.Type    = "error";
                _response.Message = "error";
                _response.data    = null;
                return(Request.CreateResponse(HttpStatusCode.OK, _response));
            }
        }