public HttpResponseMessage UpdateTableCode(OrderAPIViewModel order)
        {
            var customerDomain = new CustomerDomain();
            BaseResponse <OrderHistoryAPIViewModel> response = new BaseResponse <OrderHistoryAPIViewModel>();
            HttpResponseMessage httpResponseMessage          = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };
            var customerId = customerDomain.getCustomerIdFromToken(RequestContext);

            if (customerId != null)
            {
                order.CustomerID = customerId;
            }
            var domain = new OrderDomain();

            try
            {
                response = domain.UpdateTableCode(order, customerId.Value);
            }
            catch (ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
示例#2
0
        //public static TMATS00012020Entities objEntity = new TMATS00012020Entities();

        //public static void Register(CustomerRegistration model)
        //{
        //    objEntity.CustomerRegistrations.Add(model);
        //    objEntity.SaveChanges();
        //}

        //public static bool Login(CustomerModel model)
        //{
        //    bool result=true;
        //    var data = objEntity.CustomerRegistrations.Where(x => x.Email == model.Email && x.Password == model.Password).FirstOrDefault();
        //    if(data!=null)
        //    {
        //        result = true;
        //    }
        //    else
        //    {
        //        result = false;
        //    }
        //    return result;
        //}

        #endregion

        public static void AddToCustomer(CustomerDomain mCustomer)
        {
            string mainconn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;


            SqlConnection sqlconn = new SqlConnection(mainconn);

            sqlconn.Open();

            SqlCommand cmd = new SqlCommand("InsertCustomerReg", sqlconn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@mode", "Insert");

            cmd.Parameters.AddWithValue("@FirstName", mCustomer.FirstName);
            cmd.Parameters.AddWithValue("@LastName", mCustomer.LastName);
            cmd.Parameters.AddWithValue("@Email", mCustomer.Email);
            cmd.Parameters.AddWithValue("@Phone", mCustomer.Phone);
            cmd.Parameters.AddWithValue("@Country", mCustomer.Country);
            cmd.Parameters.AddWithValue("@State", mCustomer.State);
            cmd.Parameters.AddWithValue("@City", mCustomer.City);
            cmd.Parameters.AddWithValue("@Pincode", mCustomer.Pincode);
            cmd.Parameters.AddWithValue("@ShippingAddress", mCustomer.ShippingAddress);
            cmd.Parameters.AddWithValue("@BillingAddress", mCustomer.ShippingAddress);
            cmd.Parameters.AddWithValue("@RegistrationDatetime", DateTime.Now);
            cmd.Parameters.AddWithValue("@Password", mCustomer.Password);

            cmd.ExecuteNonQuery();

            sqlconn.Close();
        }
        public ActionResult Register(CustomerDomain model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TO DO
                    CustomerCRUD.AddToCustomer(model);
                    return(View());
                }
                return(View("Registered"));
            }
            catch (Exception ex)
            {
                ExceptionLogDomain obj = new ExceptionLogDomain();
                obj.MethodName     = "Register";
                obj.ControllerName = "Customer";
                obj.ErrorText      = ex.Message;
                obj.StackTrace     = ex.StackTrace;
                obj.Datetime       = DateTime.Now;

                ExceptionLogCRUD.AddToExceptionLog(obj);
                return(RedirectToAction("Index", "Error"));
            }
        }
        public ActionResult MyAccount()
        {
            int custid = Convert.ToInt32(Session["idUser"]);

            if (custid != 0)
            {
                var CustomerDetails = CustomerCRUD.GetCustomerById(Convert.ToInt32(Session["idUser"]));

                CustomerDomain Customer = new CustomerDomain();

                Customer.Id              = CustomerDetails[0].Id;
                Customer.FirstName       = CustomerDetails[0].FirstName;
                Customer.LastName        = CustomerDetails[0].LastName;
                Customer.Email           = CustomerDetails[0].Email;
                Customer.Phone           = CustomerDetails[0].Phone;
                Customer.Country         = CustomerDetails[0].Country;
                Customer.State           = CustomerDetails[0].State;
                Customer.City            = CustomerDetails[0].City;
                Customer.Pincode         = CustomerDetails[0].Pincode;
                Customer.ShippingAddress = CustomerDetails[0].ShippingAddress;
                Customer.BillingAddress  = CustomerDetails[0].BillingAddress;
                return(View(Customer));
            }
            else
            {
                return(RedirectToAction("Login", "Customer"));
            }
        }
示例#5
0
        public ActionResult ListSeller(CustomerSearchModel model)
        {
            FillViewBag();

            ViewBag.Customers = CustomerDomain.ListCustomers(model.Name, model.GenderId, model.CityId, model.RegionId, model.LastPurchaseStart, model.LastPuchaseEnd, model.ClassificationId, int.Parse(User.Identity.Name)).Select(c => (CustomerListModel)c);

            return(View("List"));
        }
 public static CustomerViewModel Create(CustomerDomain customerDomain)
 {
     return(new CustomerViewModel
     {
         Id = customerDomain.Id,
         Name = customerDomain.Name,
         Email = customerDomain.Email,
         Phone = customerDomain.Phone,
         PIN = customerDomain.PIN
     });
 }
示例#7
0
 public static Customer Create(CustomerDomain customerDomain)
 {
     return(new Customer
     {
         Id = customerDomain.Id,
         Name = customerDomain.Name,
         Email = customerDomain.Email,
         Phone = customerDomain.Phone,
         PIN = customerDomain.PIN
               //Products = customerDomain.Products.GetAll().Select(ProductFactory.Create);
     });
 }
        //[Route("{PromotionID?}")]
        //[HttpGet]
        public HttpResponseMessage GetPromotion(PromotionQueryRequest <dynamic> request)
        {
            var response       = new BaseResponse <dynamic>();
            var claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var customerId     = claimPrincipal.Claims.Where(c => c.Type == "CustomerId").Select(c => c.Value).SingleOrDefault();
            var cDomain        = new CustomerDomain();
            var id             = Int32.Parse(customerId);
            var customer       = cDomain.GetCustomerById(id);
            var resp           = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK
            };
            var        pDomain = new PromotionDomain();
            Membership member  = customer.MembershipVM.ToEntity();

            request.Membership = member;
            var promotion = pDomain.GetPromotion(request).ToList();

            if (promotion.Count == 0)
            {
                var res = BaseResponse <dynamic> .Get(false, "Không tìm thấy khuyến mãi nào", null, ResultEnum.PromotionNotFound);

                resp.Content    = new JsonContent(res);
                resp.StatusCode = HttpStatusCode.NotFound;
                return(resp);
            }
            try
            {
                response = BaseResponse <dynamic> .Get(false, "Thành công", null, ResultEnum.Success);

                if (promotion.Count == 1)
                {
                    response.Data = promotion.FirstOrDefault();
                }
                else
                {
                    response.Data = promotion;
                }
            }
            catch (ApiException e)
            {
                resp.StatusCode = e.StatusCode;
                response        = BaseResponse <dynamic> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                response = BaseResponse <dynamic> .Get(false, e.Message, null, ResultEnum.InternalError);

                resp.StatusCode = HttpStatusCode.InternalServerError;
            }
            resp.Content = new JsonContent(response);
            return(resp);
        }
        public HttpResponseMessage GetHistoryOrder(OrderRequest <string> request)
        {
            BaseResponse <List <OrderHistoryAPIViewModel> > response = new BaseResponse <List <OrderHistoryAPIViewModel> >();
            var domain         = new OrderDomain();
            var customerDomain = new CustomerDomain();
            HttpResponseMessage httpResponseMessage = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };
            var   customerId     = customerDomain.getCustomerIdFromToken(RequestContext);
            var   claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var   employeeId     = claimPrincipal.Claims.Where(c => c.Type == "EmployeeId").Select(c => c.Value).SingleOrDefault();
            var   userName       = claimPrincipal.Claims.Where(c => c.Type == "UserName").Select(c => c.Value).SingleOrDefault();
            Int32 employeeID     = 0;

            Int32.TryParse(employeeId, out employeeID);
            if (request.CreateAtMax.HasValue)
            {
                request.CreateAtMax = request.CreateAtMax.Value.GetEndOfDate();
            }
            if (request.CreateAtMin.HasValue)
            {
                request.CreateAtMin = request.CreateAtMin.Value.GetEndOfDate();
            }

            if (customerId != null)
            {
                request.CustomerId = customerId.Value;
            }
            if (employeeID != 0)
            {
                request.UserName = userName;
            }
            try
            {
                response = domain.GetOrderHistoryByRequest(request);
            }
            catch (ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <List <OrderHistoryAPIViewModel> > .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <List <OrderHistoryAPIViewModel> > .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
示例#10
0
        public HttpResponseMessage CheckVoucher(CheckVoucherViewModel request)
        {
            //Logger.Log("Store " + model.terminalId);
            //Logger.Log("|CheckVoucherCode| begin method");
            var response       = new BaseResponse <dynamic>();
            var claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var customerId     = claimPrincipal.Claims.Where(c => c.Type == "CustomerId").Select(c => c.Value).SingleOrDefault();
            var cDomain        = new CustomerDomain();
            var id             = Int32.Parse(customerId);
            var customer       = cDomain.GetCustomerById(id);
            var oDomain        = new OrderDomain();

            var resp = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                DateTime time    = DataService.Models.Utils.GetCurrentDateTime();
                var      pDomain = new PromotionDomain();
                var      orderVM = new OrderAPIViewModel();
                var      voucher = pDomain.GetVoucher(request.VoucherCode);
                var      mbs     = customer.MembershipVM;

                orderVM.OrderDetails = request.Data;
                orderVM.StoreID      = request.StoreId;
                AddInfo(orderVM, request);
                oDomain.CalculateOrderPrice(orderVM, time);

                //temp: each voucher has only 1 detail now
                var applyResult = pDomain.IsVoucherValidFor(voucher, orderVM, mbs);
                orderVM = pDomain.ApplyPromotionToOrder(orderVM, applyResult, mbs);

                response = BaseResponse <dynamic> .Get(true, "Thành công", orderVM, ResultEnum.Success);
            }
            catch (ApiException e)
            {
                resp.StatusCode = e.StatusCode;
                response        = BaseResponse <dynamic> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                resp.StatusCode = HttpStatusCode.InternalServerError;
                response        = BaseResponse <dynamic> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }

            resp.Content = new JsonContent(response);
            return(resp);
        }
        public HttpResponseMessage CreateOrder(OrderAPIViewModel order)
        {
            var customerDomain = new CustomerDomain();
            BaseResponse <OrderHistoryAPIViewModel> response = new BaseResponse <OrderHistoryAPIViewModel>();
            HttpResponseMessage httpResponseMessage          = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };

            #region get CustomerId and EmployeeId from Token
            var customerId = customerDomain.getCustomerIdFromToken(RequestContext);
            if (customerId != null)
            {
                order.CustomerID = customerId;
            }
            var   claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var   employeeId     = claimPrincipal.Claims.Where(c => c.Type == "EmployeeId").Select(c => c.Value).SingleOrDefault();
            var   userName       = claimPrincipal.Claims.Where(c => c.Type == "UserName").Select(c => c.Value).SingleOrDefault();
            Int32 employeeID     = 0;
            Int32.TryParse(employeeId, out employeeID);
            if (employeeID != 0)
            {
                order.EmployeeId    = employeeID;
                order.CheckInPerson = userName;
            }
            #endregion

            IOrderDomain domain = new OrderDomain();
            try
            {
                response = domain.AddOrderFromMobile(order);
            }
            catch (DataService.Utilities.ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <OrderHistoryAPIViewModel> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
示例#12
0
        public HttpResponseMessage GetVoucher([FromUri] VoucherQueryRequest <dynamic> request)
        {
            var response       = new BaseResponse <List <VoucherAPIViewModel> >();
            var claimPrincipal = (ClaimsPrincipal)RequestContext.Principal;
            var customerId     = claimPrincipal.Claims.Where(c => c.Type == "CustomerId").Select(c => c.Value).SingleOrDefault();
            var cDomain        = new CustomerDomain();
            var id             = Int32.Parse(customerId);
            var customer       = cDomain.GetCustomerById(id);
            var resp           = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK
            };
            var        pDomain = new PromotionDomain();
            Membership member  = customer.MembershipVM.ToEntity();

            request.MembershipVM = member;
            request.BrandId      = customer.BrandId;

            //if (voucher.Count == 0)
            //{
            //    var res = BaseResponse<dynamic>.Get(false, "Không tìm thấy voucher nào", null, ResultEnum.VoucherNotFound);
            //    resp.Content = new JsonContent(res);
            //    resp.StatusCode = HttpStatusCode.NotFound;
            //    return resp;
            //}
            try
            {
                var voucher = pDomain.GetVoucher(request).ToList();
                response = BaseResponse <List <VoucherAPIViewModel> > .Get(false, "Thành công", voucher, ResultEnum.Success);
            }
            catch (ApiException e)
            {
                resp.StatusCode = e.StatusCode;
                response        = BaseResponse <List <VoucherAPIViewModel> > .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                response = BaseResponse <List <VoucherAPIViewModel> > .Get(false, e.Message, null, ResultEnum.InternalError);

                resp.StatusCode = HttpStatusCode.InternalServerError;
            }
            resp.Content = new JsonContent(response);
            return(resp);
        }
示例#13
0
        public static ProductDomain Create(Product product, CustomerDomain customerDomain)
        {
            ProductDomain productDomain = new ProductDomain
            {
                Id          = product.Id,
                Name        = product.Name,
                ReleaseDate = product.ReleaseDate,
                Type        = product.Type,
                CustomerId  = product.CustomerId
            };

            if (customerDomain != null)
            {
                productDomain.Customer = customerDomain;
            }
            else
            {
                productDomain.Customer = product.Customer == null ? null : product.Customer.CreateCustomerDomain();
            }
            return(productDomain);
        }
        public HttpResponseMessage CalculateFeeDelivery(OrderAPIViewModel order)
        {
            var customerDomain = new CustomerDomain();
            BaseResponse <OrderAPIViewModel> response = new BaseResponse <OrderAPIViewModel>();
            HttpResponseMessage httpResponseMessage   = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            };
            //var customerId = customerDomain.getCustomerIdFromToken(RequestContext);
            //if (customerId != 0)
            //{
            //    order.CustomerID = customerId;
            //}
            IOrderDomain domain = new OrderDomain();

            try
            {
                var customerID = customerDomain.getCustomerIdFromToken(RequestContext);
                if (customerID != null)
                {
                    order.CustomerID = customerID;
                }
                response.Data       = domain.GetDeliveryFee(order);
                response.Message    = ConstantManager.MES_SUCCESS;
                response.ResultCode = (int)ResultEnum.Success;
                response.Success    = true;
            }
            catch (DataService.Utilities.ApiException e)
            {
                httpResponseMessage.StatusCode = e.StatusCode;
                response = BaseResponse <OrderAPIViewModel> .Get(e.Success, e.ErrorMessage, null, e.ErrorStatus);
            }
            catch (Exception e)
            {
                httpResponseMessage.StatusCode = HttpStatusCode.InternalServerError;
                response = BaseResponse <OrderAPIViewModel> .Get(false, e.ToString(), null, ResultEnum.InternalError);
            }
            httpResponseMessage.Content = new JsonContent(response);
            return(httpResponseMessage);
        }
        public static CustomerDomain Create(Customer customer)
        {
            CustomerDomain customerDomain = new CustomerDomain
            {
                Id    = customer.Id,
                Name  = customer.Name,
                Email = customer.Email,
                Phone = customer.Phone,
                PIN   = customer.PIN
            };

            if (customer.Products != null && customer.Products.Any())
            {
                var productList = new List <ProductDomain>();
                foreach (var product in customer.Products)
                {
                    productList.Add(product.CreateProductDomain(customerDomain));
                }
                customerDomain.Products = productList;
            }
            return(customerDomain);
        }
示例#16
0
        public static bool UpdateCustomerById(CustomerDomain smodel)
        {
            string        mainconn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
            SqlConnection sqlconn  = new SqlConnection(mainconn);

            SqlCommand cmd = new SqlCommand("UpdateCustomerRegistrationByID", sqlconn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Id", smodel.Id);

            cmd.Parameters.AddWithValue("@FirstName", smodel.FirstName);
            cmd.Parameters.AddWithValue("@LastName", smodel.LastName);
            cmd.Parameters.AddWithValue("@Email", smodel.Email);
            cmd.Parameters.AddWithValue("@Phone", smodel.Phone);
            cmd.Parameters.AddWithValue("@Country", smodel.Country);
            cmd.Parameters.AddWithValue("@State", smodel.State);
            cmd.Parameters.AddWithValue("@City", smodel.City);
            cmd.Parameters.AddWithValue("@Pincode", smodel.Pincode);
            cmd.Parameters.AddWithValue("@ShippingAddress", smodel.ShippingAddress);
            cmd.Parameters.AddWithValue("@BillingAddress", smodel.BillingAddress);
            //cmd.Parameters.AddWithValue("@RegistrationDatetime", smodel.RegistrationDatetime);
            //cmd.Parameters.AddWithValue("@Password", smodel.Password);
            sqlconn.Open();
            int i = cmd.ExecuteNonQuery();

            sqlconn.Close();

            if (i >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#17
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            try
            {
                var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();
                var array       = context.Scope.ToArray();
                var fbId        = array.GetValue(0).ToString();
                var brandID     = Convert.ToInt32(array.GetValue(1));
                var phone       = array.GetValue(2).ToString();
                var customerId  = Convert.ToInt32(array.GetValue(3));
                //var a = array.GetValue(1);
                //= (int)array.GetValue(1);

                ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password);


                if (user == null)
                {
                    if (fbId.Length > 0)
                    {
                        var customerDomain            = new CustomerDomain();
                        CustomerAPIViewModel customer = customerDomain.GetCustomerByBrandIdAndFbId(brandID, fbId);
                        if (customer != null)
                        {
                            ApplicationDbContext db              = new ApplicationDbContext();
                            ApplicationUser      userVM          = db.Users.FirstOrDefault(x => x.Id == customer.AspUserVM.Id);
                            ClaimsIdentity       oAuthIdentityVM = await userVM.GenerateUserIdentityAsync(userManager,
                                                                                                          OAuthDefaults.AuthenticationType);

                            ClaimsIdentity cookiesIdentityVM = await userVM.GenerateUserIdentityAsync(userManager,
                                                                                                      CookieAuthenticationDefaults.AuthenticationType);

                            AuthenticationProperties propertiesVM = CreateProperties(userVM.UserName);
                            AuthenticationTicket     ticketVM     = new AuthenticationTicket(oAuthIdentityVM, propertiesVM);
                            context.Validated(ticketVM);
                            context.Request.Context.Authentication.SignIn(cookiesIdentityVM);
                        }
                    }
                    else if (phone.Length > 0)
                    {
                        var customerDomain = new CustomerDomain();
                        CustomerAPIViewModel customerByPhone = customerDomain.GetCustomersByPhonenumber(phone, brandID);
                        if (customerByPhone != null)
                        {
                            ApplicationDbContext db              = new ApplicationDbContext();
                            ApplicationUser      userVM          = db.Users.FirstOrDefault(x => x.Id == customerByPhone.AspUserVM.Id);
                            ClaimsIdentity       oAuthIdentityVM = await userVM.GenerateUserIdentityAsync(userManager,
                                                                                                          OAuthDefaults.AuthenticationType);

                            ClaimsIdentity cookiesIdentityVM = await userVM.GenerateUserIdentityAsync(userManager,
                                                                                                      CookieAuthenticationDefaults.AuthenticationType);

                            AuthenticationProperties propertiesVM = CreateProperties(userVM.UserName);
                            AuthenticationTicket     ticketVM     = new AuthenticationTicket(oAuthIdentityVM, propertiesVM);
                            context.Validated(ticketVM);
                            context.Request.Context.Authentication.SignIn(cookiesIdentityVM);
                        }
                    }
                    else if (customerId > 0)
                    {
                        var customerDomain = new CustomerDomain();
                        CustomerAPIViewModel customerById = customerDomain.GetCustomerById(customerId);
                        if (customerById != null)
                        {
                            ApplicationDbContext db              = new ApplicationDbContext();
                            ApplicationUser      userVM          = db.Users.FirstOrDefault(x => x.Id == customerById.AspUserVM.Id);
                            ClaimsIdentity       oAuthIdentityVM = await userVM.GenerateUserIdentityAsync(userManager,
                                                                                                          OAuthDefaults.AuthenticationType);

                            ClaimsIdentity cookiesIdentityVM = await userVM.GenerateUserIdentityAsync(userManager,
                                                                                                      CookieAuthenticationDefaults.AuthenticationType);

                            AuthenticationProperties propertiesVM = CreateProperties(userVM.UserName);
                            AuthenticationTicket     ticketVM     = new AuthenticationTicket(oAuthIdentityVM, propertiesVM);
                            context.Validated(ticketVM);
                            context.Request.Context.Authentication.SignIn(cookiesIdentityVM);
                        }
                    }
                    else
                    {
                        context.SetError("invalid_grant", "The user name or password is incorrect.");
                        return;
                    }
                }
                else
                {
                    ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                        OAuthDefaults.AuthenticationType);

                    ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                          CookieAuthenticationDefaults.AuthenticationType);

                    AuthenticationProperties properties = CreateProperties(user.UserName);
                    AuthenticationTicket     ticket     = new AuthenticationTicket(oAuthIdentity, properties);
                    context.Validated(ticket);
                    context.Request.Context.Authentication.SignIn(cookiesIdentity);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 public CustomerAddController()
 {
     this.CustomerDomain = new CustomerDomain();
 }
示例#19
0
 private static void Display(CustomerDomain customerDomain)
 {
     Console.Write("Product name: {0}", customerDomain.Name);
 }
示例#20
0
        static void Main(string[] args)
        {
            bool           carryon = true;
            char           ch;
            int            i;
            OrderDomain    orderDomain    = new OrderDomain();
            CustomerDomain customerDomain = new CustomerDomain();
            CompanyDomain  companyDomain  = new CompanyDomain();

            Console.WriteLine("----------------Welcome in ToySelling Application-------------");
            while (carryon)
            {
                Console.WriteLine("\n1. Customer Registration\t2.Company Registration\n3. Add Toy In Production\t 4. View Toys\n5. View Customers \n6 . Add Shipping Address\t7. Show Address \n 8. Add Order In Cart\t9. View Cart Order  \n10. Place Order \t 11. View Invoice\n\nEnter Your Choice : ");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    Customer customer = new Customer();
                    Console.WriteLine("\nEnter Name :");
                    customer.Name = Console.ReadLine();
                    Console.WriteLine("\nEnter Mobile No :");
                    customer.MobileNo = Convert.ToInt32(Console.ReadLine()).ToString();
                    Console.WriteLine("\nEnter City :");
                    customer.City = Console.ReadLine();

                    customerDomain.AddCustomer(customer);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 2:
                    Company company = new Company();
                    Console.WriteLine("\nEnter Name :");
                    company.CompanyName = Console.ReadLine();
                    Console.WriteLine("\nEnter City :");
                    company.City = Console.ReadLine();

                    companyDomain.AddCompany(company);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 3:
                    ToyProduction toyProduction = new ToyProduction();
                    Console.WriteLine("\nEnter Toy Id :");
                    toyProduction.ToyId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter CompanyId :");
                    toyProduction.CompanyId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Price :");
                    toyProduction.Price = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Quantity :");
                    toyProduction.Quantity = Convert.ToInt32(Console.ReadLine());
                    CompanyDomain companyDomain1 = new CompanyDomain();
                    companyDomain1.AddToyProduction(toyProduction);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 4:
                    CompanyDomain cd = new CompanyDomain();
                    i = 1;
                    foreach (ToyProduction toy in cd.GetToyProduction())
                    {
                        Console.WriteLine("Toy - " + i);
                        Console.WriteLine("ToyProductionId : " + toy.ProductionId);
                        Console.WriteLine("ToyId : " + toy.ToyId);
                        Console.WriteLine("CompanyId : " + toy.CompanyId);
                        Console.WriteLine("Price : " + toy.Price);
                        Console.WriteLine("Total Toy : " + toy.Quantity);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 5:
                    foreach (Customer customer1 in customerDomain.GetCustomers())
                    {
                        Console.WriteLine("Customer Id : " + customer1.CustomerId);
                        Console.WriteLine("Name : " + customer1.Name);
                        Console.WriteLine("Mobile No : " + customer1.MobileNo);
                        Console.WriteLine("Ciry : " + customer1.City);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 6:
                    CustomerAddress customerAddress = new CustomerAddress();
                    Console.WriteLine("\nEnter Address :");
                    customerAddress.Address = Console.ReadLine();
                    Console.WriteLine("\nEnter Custermer Id :");
                    customerAddress.CustomerId = Convert.ToInt32(Console.ReadLine());
                    CustomerDomain cust = new CustomerDomain();
                    cust.AddAddress(customerAddress);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 7:
                    CustomerAddress ca = new CustomerAddress();
                    Console.WriteLine("Enter Customer Id :");
                    ca.CustomerId = Convert.ToInt32(Console.ReadLine());
                    foreach (CustomerAddress customer1 in customerDomain.GetCustomerAddresses(ca))
                    {
                        Console.WriteLine("Customer Id : " + customer1.CustomerId);
                        Console.WriteLine("Address Id : " + customer1.AddressId);
                        Console.WriteLine("Address : " + customer1.Address);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 8:
                    Order order = new Order();
                    Console.WriteLine("\nEnter Custermer Id :");
                    order.CustomerId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter ToyProduction Id :");
                    order.ProductionId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Quantity :");
                    order.Quantity = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Shipping Address Id :");
                    order.AddressId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("\nEnter Order Date :");
                    order.OrderDate = Convert.ToDateTime(Console.ReadLine());

                    orderDomain.AddOrder(order);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 9:
                    foreach (Order orders in orderDomain.GetOrders())
                    {
                        Console.WriteLine("Order Id : " + orders.OderId);
                        Console.WriteLine("ToyId : " + orders.CustomerId);
                        Console.WriteLine("ToyId : " + orders.ProductionId);
                        Console.WriteLine("AddressId : " + orders.AddressId);
                        Console.WriteLine("------------------------------------------------");
                    }
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }

                    break;

                case 10:
                    orderDomain.GetOrderById();
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                case 11:
                    Invoice invoice = new Invoice();
                    invoice = orderDomain.GetInvoiceById();
                    Console.WriteLine("Invoice Id :" + invoice.InvoiceId);
                    Console.WriteLine("Order Id :" + invoice.OrderId);
                    Console.WriteLine("Price :" + invoice.Price);
                    Console.WriteLine("Offer Id :" + invoice.OfferId);
                    Console.WriteLine("Final Price :" + invoice.FinalPrice);
                    Console.WriteLine("\nDo you want to continue? Press y for yes");
                    ch = Convert.ToChar(Console.ReadLine());
                    if (ch.Equals('y') || ch.Equals('Y'))
                    {
                        carryon = true;
                    }
                    else
                    {
                        carryon = false;
                    }
                    break;

                default:
                    carryon = false;
                    break;
                }
            }
        }
示例#21
0
 public CustomerController()
 {
     this.customerDomain = new CustomerDomain();
 }
 public static CustomerViewModel CreateCustomerViewModel(this CustomerDomain customerDomain)
 {
     return(Create(customerDomain));
 }
示例#23
0
 public static ProductDomain CreateProductDomain(this Product product, CustomerDomain customerDomain = null)
 {
     return(Create(product, customerDomain));
 }
示例#24
0
 public static CustomerViewModel Create(CustomerDomain customerDomain)
 {
     return(new CustomerViewModel {
         Id = customerDomain.Id, Name = customerDomain.Name
     });
 }
        static void Main(string[] args)
        {
            Customer       customer20     = new Customer();
            Plant          plant10        = new Plant();
            ToyDomain      toyDomain      = new ToyDomain();
            PlantDomain    plantDomain    = new PlantDomain();
            ToyType        toyType10      = new ToyType();
            Customer       customer       = new Customer();
            ToyTypeDomain  toyTypeDomain  = new ToyTypeDomain();
            CustomerDomain customerDomain = new CustomerDomain();
            OrderDomain    orderDomain    = new OrderDomain();

repeate:
            Console.WriteLine("--->>Welcome to Toy Store application<<---");

            Console.WriteLine("-->>Choose form the below given options<<--");

            Console.WriteLine("=1.1:->Enter ToyType..{this option adds which type of toy you Manufacturing}");
            Console.WriteLine("=1.2:->Show list of ToyTypes..{this option shows whole list of entered ToyTypes}");
            Console.WriteLine("=1.3:->Delete ToyType..{this option deletes selected field}");
            Console.WriteLine("=2.1:->Enter Plant..{this option adds the information regarding to the Manufacturing Plants}");
            Console.WriteLine("=2.2:->Show  list of Plants..{this option shows list of Manufacturing Plants}");
            Console.WriteLine("=2.3:->Delete Plant..{this option deletes Manufacturing plants}");
            Console.WriteLine("=3.1:->Enter Customer..{this option adds the information regarding to Customer}");
            Console.WriteLine("=3.2:->Show list of Customers..{this option shows list of Customers}");
            Console.WriteLine("=3.3:->Delete Customer..{this option deletes Customers}");
            Console.WriteLine("=4.1:->Enter Toys..{this option adds information regarding to the Toys}");
            Console.WriteLine("=4.2:->Show list of Toys..{this option shows the list of enterd Toys}");
            Console.WriteLine("=5.1:->Enter Order..{this option adds order details}");
            Console.WriteLine("=5.2:->Show list of Orders..{this option shows the list of enterd Orders}");
            Console.WriteLine("Enter any other numeric key to Exit the program");
            double c = double.Parse(Console.ReadLine());

            switch (c)
            {
            case 1.1:
                toyTypeDomain.AddToyType();
                Console.WriteLine("");
                goto repeate;

            case 1.2:
                Console.WriteLine("Id\t ToyType");
                foreach (ToyType toyType in toyTypeDomain.GetToyType())
                {
                    Console.WriteLine($"{toyType.ToyTypeId}\t  {toyType.ToyTypeName}");
                }
                Console.WriteLine("");
                goto repeate;

            case 1.3:
                Console.WriteLine("--->>Delete ToyType<<---");
                Console.WriteLine("Enter typeId");
                toyType10.ToyTypeId = Int32.Parse(Console.ReadLine());
                toyTypeDomain.DeleteToyType(toyType10);
                Console.WriteLine("");
                goto repeate;

            case 2.1:
                plantDomain.AddPlant();
                Console.WriteLine("");
                goto repeate;

            case 2.2:
                Console.WriteLine("Id\tPlantName PlantAddress");
                foreach (Plant plant in plantDomain.GetAllPlant())
                {
                    Console.WriteLine($"{plant.PlantId}\t{plant.PlantName}\t\t{plant.PlantAddress}");
                }
                Console.WriteLine("");
                goto repeate;

            case 2.3:
                Console.WriteLine("--->> Delete Plant <<---");
                Console.WriteLine("Enter Id To delete Plant: ");
                plant10.PlantId = Int32.Parse(Console.ReadLine());
                plantDomain.DeletePlant(plant10);
                Console.WriteLine("");
                goto repeate;

            case 3.1:
                customerDomain.AddCustomer();
                Console.WriteLine("");
                goto repeate;

            case 3.2:
                Console.WriteLine("\n--->> View All Customers <<---");

                Console.WriteLine("Id \t CustomerName \t CustomerAddress");
                foreach (Customer customer1 in customerDomain.GetAllCustomers())
                {
                    Console.WriteLine($"{customer1.CustomerId}\t  {customer1.CustomerName}\t\t{customer1.CustomerPermanentAddress} ");
                }
                Console.WriteLine("");
                goto repeate;

            case 3.3:
                Console.WriteLine("--->> Delete Plant <<---");
                Console.WriteLine("Enter Id To delete Plant: ");
                customer20.CustomerId = Int32.Parse(Console.ReadLine());
                customerDomain.DeleteCustomer(customer20);
                Console.WriteLine("");
                goto repeate;

            case 4.1:
                toyDomain.AddToy();
                Console.WriteLine("");
                goto repeate;

            case 4.2:
                Console.WriteLine("\n--->> View All Toys <<---");

                Console.WriteLine("Id \t ToyPrice\tToyTypeId\tPlantId");
                foreach (Toy toy in toyDomain.GetAllToy())
                {
                    Console.WriteLine($"{toy.ToyId}\t  {toy.ToyPrice}\t\t{toy.ToyTypeId}\t\t{toy.PlantId} ");
                }
                Console.WriteLine("");
                goto repeate;

            case 5.1:
                orderDomain.AddOrder();
                Console.WriteLine("");
                goto repeate;

            case 5.2:
                Console.WriteLine("\n--->> View All Orders <<---");

                Console.WriteLine("Id \tQuantity\tAddress\tDiscount\tToyId\tCustomerId");
                foreach (Order order in orderDomain.GetAllOrders())
                {
                    Console.WriteLine($"{order.OrderId}\t{order.OrderQuantity}\t\t{order.OrderAddress}\t{order.OrderDiscount}\t\t{order.ToyId}\t\t{order.CustomerId} ");
                }
                Console.WriteLine("");
                goto repeate;

            default:
                break;
            }

            /* customerDomain.AddCustomer();*/

            /*Console.WriteLine("\n--->> View All Customers <<---");
             *
             * Console.WriteLine("Id \t CustomerName \t CustomerAddress");
             * foreach (Customer customer1 in customerDomain.GetAllCustomers())
             * {
             *
             *  Console.WriteLine($"{customer1.CustomerId}\t  {customer1.CustomerName}\t\t{customer1.CustomerPermanentAddress} ");
             * }
             *
             *
             * Console.WriteLine("--->> Delete Customer <<---");
             * Console.WriteLine("Enter Id To delete Customer: ");
             * customer.CustomerId = Int32.Parse(Console.ReadLine());
             *
             *
             * Console.WriteLine("Hello World!");
             * Console.ReadLine();*/

            /*toyTypeDomain.AddToyType();*/

            /*Console.Writeline("Delete ToyType");
             * Console.WriteLine("Enter typeId");
             * toyType.ToyTypeId = Int32.Parse(Console.ReadLine());
             * toyTypeDomain.DeleteToyType(toyType);*/

            /*toyDomain.AddToy();*/

            /*Console.WriteLine("\n--->> View All Toys <<---");
             *
             * Console.WriteLine("Id \t ToyPrice\tToyTypeId\tPlantId" );
             * foreach (Toy toy in toyDomain.GetAllToy())
             * {
             *  Console.WriteLine($"{toy.ToyId}\t  {toy.ToyPrice}\t\t{toy.ToyTypeId}\t\t{toy.PlantId} ");
             * }*/


            //orderDomain.AddOrder();

            /*Console.WriteLine("\n--->> View All Orders <<---");
             *
             * Console.WriteLine("Id \tQuantity\tAddress\tDiscount\tToyId\tCustomerId");
             * foreach (Order order in orderDomain.GetAllOrders())
             * {
             *  Console.WriteLine($"{order.OrderId}\t{order.OrderQuantity}\t\t{order.OrderAddress}\t{order.OrderDiscount}\t\t{order.ToyId}\t\t{order.CustomerId} ");
             * }*/
        }
        public ActionResult UpdateCustomer(CustomerDomain model)
        {
            var result = CustomerCRUD.UpdateCustomerById(model);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#27
0
 public static Customer CreateCustomer(this CustomerDomain customerDomain)
 {
     return(Create(customerDomain));
 }