예제 #1
0
        public static Customer LoadByID(int id)
        {
            try
            {
                using (DVDCentralEntities dc = new DVDCentralEntities())
                {
                    //get the row i want to load
                    tblCustomer row = (from dt in dc.tblCustomers
                                       where dt.Id == id
                                       select dt).FirstOrDefault();

                    if (row != null)
                    {
                        return new Customer {
                                   Id = row.Id, FirstName = row.FirstName, LastName = row.LastName, Address = row.Address, City = row.City, State = row.State, ZIP = row.ZIP, Phone = row.Phone, UserId = row.UserID
                        }
                    }
                    ;
                    else
                    {
                        throw new Exception("Row not found");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public static int Update(Customer customer)
        {
            try
            {
                using (DVDCentralEntities dc = new DVDCentralEntities())
                {
                    //get the row i want to update
                    tblCustomer updateRow = (from dt in dc.tblCustomers
                                             where dt.Id == customer.Id
                                             select dt).FirstOrDefault();

                    if (updateRow != null)
                    {
                        updateRow.FirstName = customer.FirstName;
                        updateRow.LastName  = customer.LastName;
                        updateRow.Address   = customer.Address;
                        updateRow.City      = customer.City;
                        updateRow.State     = customer.State;
                        updateRow.ZIP       = customer.ZIP;
                        updateRow.UserID    = customer.UserId;
                        updateRow.Phone     = customer.Phone;

                        return(dc.SaveChanges());
                    }
                    else
                    {
                        throw new Exception("Row not found");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
    public static string UserLogin(string EmailID)
    {
        string s = "";

        if (HttpContext.Current.Session[appFunctions.Session.ClientUserID.ToString()] == null)
        {
            PageBase objPageBase = new PageBase();

            if (!string.IsNullOrEmpty(EmailID))
            {
                tblCustomer objCustomer = new tblCustomer();
                objCustomer.Where.AppEmailID.Value = EmailID;
                objCustomer.Query.Load();
                if (objCustomer.RowCount > 0)
                {
                    HttpContext.Current.Session[appFunctions.Session.ClientUserID.ToString()]   = objCustomer.AppCustomerID;
                    HttpContext.Current.Session[appFunctions.Session.ClientUserName.ToString()] = objCustomer.AppFirstName + " " + objCustomer.AppLastName;
                    s = "true";
                    //HttpContext.Current.Response.Redirect(objPageBase.GetAlias("MyAccount.aspx"));
                }
                else
                {
                    // Response.Redirect(objPageBase.GetAlias("RegisterWithFB.aspx"));
                }
            }
        }
        else
        {
            s = "";
        }
        return(s);
    }
예제 #4
0
        public IHttpActionResult PosttblCustomer(tblCustomer tblCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tblCustomers.Add(tblCustomer);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (tblCustomerExists(tblCustomer.CusId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tblCustomer.CusId }, tblCustomer));
        }
        public async Task <List <tblCustomer> > QuickPostNew_UpdateCustomerToServer(tblCustomer customer)
        {
            List <tblCustomer> lstCustomerResponse = new List <tblCustomer>();

            using (var client = new HttpClient())
            {
                try
                {
                    // serialized the object. ( Convert to JSON string)
                    var jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(customer);

                    string URL = "http://" + ServerIPAddress + "/api/Masters/Sync_CustomerData";

                    // set the content
                    StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");

                    // post the data and get the response.
                    HttpResponseMessage response = await client.PostAsync(URL, content);

                    //extract the response in json string format.
                    string strResponse = await response.Content.ReadAsStringAsync();

                    // get the Response in Class-object format. ( DeSerialized it)
                    lstCustomerResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <List <tblCustomer> >(strResponse);
                }
                catch (Exception ex)
                {
                }
            }
            return(lstCustomerResponse);
        }
예제 #6
0
        public ActionResult InsertUser()
        {
            ViewBag.message = false;
            try
            {
                if (ModelState.IsValid)
                {
                    tblCustomer newCust = new tblCustomer();
                    newCust.CustomerName  = Request.Form["CustomerName"];
                    newCust.CustomerEmail = Request.Form["CustomerEmail"];
                    newCust.PhoneNumber   = Request.Form["PhoneNo"];
                    newCust.Password      = Request.Form["Password"];
                    newCust.IsActive      = false;
                    newCust.CreatedDate   = DateTime.Now;

                    if (ModelState.IsValid)
                    {
                        int              fileSize = 0;
                        string           fileName = string.Empty;
                        string           mimeType = string.Empty;
                        System.IO.Stream fileContent;

                        if (Request.Files.Count > 0)
                        {
                            HttpPostedFileBase file = Request.Files[0];

                            fileSize    = file.ContentLength;
                            fileName    = file.FileName;
                            mimeType    = file.ContentType;
                            fileContent = file.InputStream;


                            if (mimeType.ToLower() != "image/jpeg" && mimeType.ToLower() != "image/jpg" && mimeType.ToLower() != "image/png")
                            {
                                return(Json(new { Formatwarning = true, message = "Profile pic format must be JPEG or JPG or PNG." }, JsonRequestBehavior.AllowGet));
                            }

                            #region Save And compress file
                            //To save file, use SaveAs method
                            file.SaveAs(Server.MapPath("~/CustomerProfile/") + fileName);
                            if (!ImageProcessing.InsertImages(Server.MapPath("~/CustomerProfile/") + fileName))
                            {
                                return(Json(new { success = false, message = "Error occur while uploading image." }, JsonRequestBehavior.AllowGet));
                            }
                            #endregion
                        }
                        newCust.ProfilePic = fileName;
                    }
                    db.tblCustomers.Add(newCust);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = "Record not Inserted" }, JsonRequestBehavior.AllowGet));
            }


            return(Json(new { success = true, message = "Record inserted" }, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public IHttpActionResult UpdateEmail(string username, tblCustomer customer)
        {
            /*if (!ModelState.IsValid)
             * {
             *  return BadRequest(ModelState);
             * }*/

            try
            {
                tblCustomer newcustomer = new tblCustomer();
                newcustomer = db.tblCustomers.Find(username);
                if (newcustomer != null)
                {
                    newcustomer.EmailId = customer.EmailId;

                    db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Ok(customer));
        }
예제 #8
0
        public bool AddCustomer(out int customerId, tblCustomer customer)
        {
            customerId = 0;

            var isCheck = web365db.tblCustomer.Count(c => c.Email == customer.Email && c.IsActive == true) > 0;

            if (isCheck)
            {
                return(isCheck);
            }

            customer.Password    = Web365Utility.Web365Utility.MD5Hash(customer.Password);
            customer.DateCreated = DateTime.Now;
            customer.DateUpdated = DateTime.Now;
            customer.IsActive    = true;
            customer.IsDeleted   = false;

            web365db.tblCustomer.Add(customer);

            var result = web365db.SaveChanges();

            customerId = customer.ID;

            return(result > 0);
        }
예제 #9
0
        private SQLQueryResult AddNewCustomer(PharmacyDBContext appDBContext, object[] paramaters)
        {
            tblCustomer newCustomer = paramaters[0] as tblCustomer;
            string      imageFolder = paramaters[1] as string;

            SQLQueryResult result = new SQLQueryResult(null, MessageQueryResult.Non);

            try
            {
                appDBContext.tblCustomers.Add(newCustomer);

                if (!SaveImageToFile((appDBContext.tblCustomers.ToList().Count + 1).ToString(), imageFolder, ImageType.Customer))
                {
                    result = new SQLQueryResult(null, MessageQueryResult.Aborted);
                    return(result);
                }

                appDBContext.SaveChanges();
                result = new SQLQueryResult(newCustomer, MessageQueryResult.Done);
            }
            catch (DbEntityValidationException e)
            {
                HandleDbEntityValidationException(e);
                result = new SQLQueryResult(null, MessageQueryResult.Aborted);
            }
            catch (Exception e)
            {
                ShowErrorMessageBox(e);
                result = new SQLQueryResult(null, MessageQueryResult.Aborted);
            }

            return(result);
        }
예제 #10
0
        public void SaveBulkCustomerDetails(List <CustomerModel> CustomerModel)
        {
            var CompanyId = CustomerModel.Select(t => t.CompanyId).FirstOrDefault();
            var customers = entity.tblCustomers.Where(c => c.COMPANYID == CompanyId);

            foreach (var item in customers)
            {
                entity.tblCustomers.Remove(item);
            }
            foreach (var item in CustomerModel)
            {
                var customer = new tblCustomer()
                {
                    ADDRESS1     = item.Address1,
                    ADDRESS2     = item.Address2,
                    ADDED_DATE   = item.AddedDate,
                    COMPANYID    = item.CompanyId,
                    CUSTOMERCODE = item.CustomerCode,
                    FIRSTNAME    = item.FirstName,
                    LASTNAME     = item.LastName,
                    OFFICENAME   = item.OfficeName,
                    EMAIL        = item.Email,
                    LAT          = item.Lat,
                    LNG          = item.Lng,
                    PHONE_1      = item.Phone1,
                    PHONE_2      = item.Phone2,
                    WEBSITE      = item.Website,
                    ZIPCODE      = item.ZipCode
                };
                entity.tblCustomers.Add(customer);
            }
            entity.SaveChanges();
        }
예제 #11
0
        public void GetCustomerBalanceTest()
        {
            tblInvoice  invoice  = dc.tblInvoices.Where(i => i.Status == "Issued").FirstOrDefault();
            tblCustomer customer = dc.tblCustomers.Where(c => c.Id == invoice.CustomerId).FirstOrDefault();

            decimal expected = invoice.ServiceRate * customer.PropertySqFt;
            decimal actual   = 0;


            var customerId = new SqlParameter
            {
                ParameterName = "customerId",
                SqlDbType     = System.Data.SqlDbType.UniqueIdentifier,
                Value         = customer.Id
            };

            var results = dc.Set <spGetCustomerBalanceResult>().FromSqlRaw("exec spGetCustomerBalance @customerId", customerId).ToList();

            foreach (var r in results)
            {
                actual = r.Balance;
            }

            Assert.AreEqual(expected, actual);
        }
예제 #12
0
        public void InsertTest()
        {
            int expected = 1;
            int actual   = 0;

            Guid userId = dc.tblUsers.First().Id;

            tblCustomer newCustomer = new tblCustomer
            {
                Id            = Guid.NewGuid(),
                City          = "Appleton",
                StreetAddress = "123 Easy Street",
                Email         = "*****@*****.**",
                FirstName     = "Bill",
                LastName      = "Jenkins",
                Phone         = "123-456-7890",
                State         = "WI",
                UserId        = userId,
                ZipCode       = "54901",
                PropertySqFt  = 50000
            };

            dc.tblCustomers.Add(newCustomer);
            actual = dc.SaveChanges();

            customerId = newCustomer.Id;

            Assert.AreEqual(expected, actual);
        }
예제 #13
0
        public static int Update(int id, int userId, string firstName, string lastName, string address, string city,
                                 string state, string zip, string phone)
        {
            try
            {
                using (DVDCentralEntities dc = new DVDCentralEntities())
                {
                    tblCustomer updaterow = (from dt in dc.tblCustomers
                                             where dt.Id == id
                                             select dt).FirstOrDefault();

                    updaterow.UserId    = userId;
                    updaterow.FirstName = firstName;
                    updaterow.LastName  = lastName;
                    updaterow.Address   = address;
                    updaterow.City      = city;
                    updaterow.State     = state;
                    updaterow.ZIP       = zip;
                    updaterow.Phone     = phone;

                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
        public static int Insert(out int id, int userId, string firstName, string lastName, string address,
                                 string city, string state, string zip, string phone)
        {
            try
            {
                using (DVDCentralEntities dc = new DVDCentralEntities())
                {
                    tblCustomer newrow = new tblCustomer();

                    newrow.UserId    = userId;
                    newrow.FirstName = firstName;
                    newrow.LastName  = lastName;
                    newrow.Address   = address;
                    newrow.City      = city;
                    newrow.State     = state;
                    newrow.ZIP       = zip;
                    newrow.Phone     = phone;

                    //giving a new row the next id after existing one or if there is none id equals to 1
                    newrow.Id = dc.tblCustomers.Any() ? dc.tblCustomers.Max(dt => dt.Id) + 1 : 1;

                    id = newrow.Id;

                    dc.tblCustomers.Add(newrow);

                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #15
0
        public HttpResponseMessage PostLogin(string username, string Password_)
        {
            bool               Exists = false;
            tblCustomer        login  = new tblCustomer();
            List <tblCustomer> admins = db.tblCustomers.ToList();

            foreach (var item in admins)
            {
                if (item.username == username)
                {
                    Exists = true;
                    login  = item;
                    break;
                }
            }

            if (Exists)
            {
                if (login.Password_ == Password_)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Wrong Password"));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Invalid User"));
            }
        }
예제 #16
0
        public IHttpActionResult PuttblCustomer(int id, tblCustomer tblCustomer)
        {
            Console.WriteLine("Hello");
            tblCustomer oldDetails = tblCustomer;


            if (!ModelState.IsValid)
            {
                return(BadRequest("Not valid data"));
            }


            using (db)
            {
                var cust = db.tblCustomers.Where(g => g.cust_Id.Equals(id)).FirstOrDefault();
                if (cust != null)
                {
                    cust.cust_Firstname  = tblCustomer.cust_Firstname;
                    cust.cust_Lastname   = tblCustomer.cust_Lastname;
                    cust.cust_Contact    = tblCustomer.cust_Contact;
                    cust.cust_Cardnumber = tblCustomer.cust_Cardnumber;
                    cust.cust_Email      = tblCustomer.cust_Email;
                    cust.cust_Password   = tblCustomer.cust_Password;

                    var res = db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            return(Ok());
        }
예제 #17
0
        public IHttpActionResult RefundWallet(string username, float refunddetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                tblCustomer newcustomer = new tblCustomer();
                newcustomer = db.tblCustomers.Find(username);
                if (newcustomer != null)
                {
                    newcustomer.WalletDetails += refunddetails;

                    db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Ok());
        }
        public async Task <IActionResult> Edit(int id, [Bind("cusid,First_Name,Last_Name,Email,CNIC,mobileno,city,state,country")] tblCustomer tblCustomer)
        {
            if (id != tblCustomer.cusid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblCustomer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tblCustomerExists(tblCustomer.cusid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["city"] = new SelectList(_context.tblCity, "city_Id", "city_Id", tblCustomer.city);
            return(View(tblCustomer));
        }
예제 #19
0
        public IHttpActionResult ResetPassword(string username, tblCustomer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                tblCustomer newcustomer = new tblCustomer();
                newcustomer = db.tblCustomers.Find(username);
                if (newcustomer != null)
                {
                    newcustomer.Password_ = customer.Password_;

                    db.SaveChanges();
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Ok(customer));
        }
예제 #20
0
        public int Insert()
        {
            try
            {
                using (DVDEntities dc = new DVDEntities())
                {
                    tblCustomer customer = new tblCustomer
                    {
                        FirstName = this.FirstName,
                        LastName  = this.LastName,
                        Address   = this.Address,
                        City      = this.City,
                        Phone     = this.Phone,
                        State     = this.State,
                        UserId    = this.UserId,
                        ZIP       = this.ZIP,
                        Id        = dc.tblCustomers.Any() ? dc.tblCustomers.Max(c => c.Id) + 1 : 1
                    };
                    this.Id = customer.Id;
                    dc.tblCustomers.Add(customer);

                    //Return the rows effected
                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SetUpPageContent(ref metaDescription, ref metaKeywords);
            objCommon = new clsCommon();
            string strIds = objCommon.GetParameterFromUrl(Enums.Enums_URLParameterType.ByNumber, "1");

            if (strIds != "")
            {
                Boolean approved = false;
                try
                {
                    string      strId       = objEncrypt.Decrypt(strIds, appFunctions.strKey);
                    tblCustomer objCustomer = new tblCustomer();
                    if (objCustomer.LoadByPrimaryKey(Convert.ToInt32(strId)))
                    {
                        if (!(objCustomer.AppIsVerified))
                        {
                            objCustomer.AppIsVerified = true;
                            objCustomer.Save();
                            approved = true;
                        }
                    }
                    objCustomer = null;
                    Response.Redirect(GetAlias("Login.aspx") + "?From=" + objEncrypt.Encrypt("ApprovedPage" + approved.ToString(), appFunctions.strKey), true);
                }
                catch (Exception ex)
                {
                }
            }
            objCommon = null;
        }
    }
예제 #22
0
        public JsonResult Delete(string id)
        {
            var obj = new tblCustomer();

            //Check tồn tại trong cardcustomer
            var existedInCard = _tblCardService.GetAllByCustomerId(id);

            if (existedInCard.Any())
            {
                var result1 = new MessageReport();
                result1.Message   = "Khách hàng đang sử dụng thẻ. Không thể xóa.";
                result1.isSuccess = false;
            }

            //Check tồn tại trong event
            //var existedInEvent = _PK_VehicleEventService.GetAllEventByCustomerId(id);
            //if (existedInEvent.Any())
            //{
            //    var result1 = new Result();
            //    result1.ErrorCode = 500;
            //    result1.Message = "Khách hàng đang tồn tại trong sự kiện. Không thể xóa.";
            //    result1.Success = false;
            //}

            var result = _tblCustomerService.DeleteById(id, ref obj);

            if (result.isSuccess)
            {
                WriteLog.Write(result, GetCurrentUser.GetUser(), obj.CustomerID.ToString(), obj.CustomerCode, "tblCustomer", ConstField.AccessControlCode, ActionConfigO.Delete);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #23
0
        public ActionResult Action(tblCustomer objSubmit)
        {
            if (objSubmit.ID == 0)
            {
                objSubmit.DateCreated = DateTime.Now;
                objSubmit.DateUpdated = DateTime.Now;
                objSubmit.IsDeleted   = false;
                objSubmit.IsActive    = true;
                customerRepository.Add(objSubmit);
            }
            else
            {
                var obj = customerRepository.GetById <tblCustomer>(objSubmit.ID);

                UpdateModel(obj);

                objSubmit.DateUpdated = DateTime.Now;

                customerRepository.Update(obj);
            }

            return(Json(new
            {
                Error = false
            }, JsonRequestBehavior.AllowGet));
        }
예제 #24
0
        public IHttpActionResult PuttblCustomer(string id, tblCustomer tblCustomer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblCustomer.CusId)
            {
                return(BadRequest());
            }

            db.Entry(tblCustomer).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblCustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #25
0
    private void SetValuesToControls()
    {
        if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
        {
            objOrder = new tblOrder();
            if (objOrder.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)))
            {
                lblOrderNo.Text                = objOrder.s_AppOrderNo;
                ddlstatus.SelectedValue        = objOrder.s_AppOrderStatusID;
                lblOrderAmount.Text            = objOrder.s_AppOrderAmount;
                lblReceiverName.Text           = objOrder.s_AppReceiverName;
                lblReceiverContactNo1.Text     = objOrder.s_AppReceiverContactNo1;
                lblReceiverContactNo2.Text     = objOrder.s_AppReceiverContactNo2;
                lblRecevierEmail.Text          = objOrder.s_AppRecevierEmail;
                lblReceiverAddress.Text        = objOrder.s_AppReceiverAddress;
                lblPreferedTime.Text           = objOrder.s_AppPreferedTime;
                lblBillReceiverName.Text       = objOrder.s_AppBillReceiverName;
                lblBillReceiverContactNo1.Text = objOrder.s_AppBillReceiverContactNo1;
                lblBillReceiverContactNo2.Text = objOrder.s_AppBillReceiverContactNo2;
                lblBillRecevierEmail.Text      = objOrder.s_AppBillRecevierEmail;
                lblBillReceiverAddress.Text    = objOrder.s_AppBillReceiverAddress;

                tblCustomer objCust = new tblCustomer();

                if (objCust.LoadByPrimaryKey(objOrder.AppCustomerID))
                {
                    lblCustomer.Text       = objCust.s_AppFirstName + " " + objCust.s_AppLastName;
                    lblCustomerMobile.Text = objCust.s_AppMobile;
                    lblCustomerEmail.Text  = objCust.s_AppEmailID;
                }
                objCust = null;
            }
            objOrder = null;
        }
    }
    public bool SendPassword()
    {
        tblCustomer objCustomer = new tblCustomer();

        objCustomer.Where.AppEmailID.Value = txtEmail.Text;
        objCustomer.Query.Load();
        if (objCustomer.RowCount > 0)
        {
            clsCommon     objCommon  = new clsCommon();
            clsEncryption objEncrypt = new clsEncryption();
            string        StrBody    = "";
            string        strSubject = "Password Recovery Request";
            StrBody = objCommon.readFile(Server.MapPath("~/EmailTemplates/ForgetPassword.html"));
            StrBody = StrBody.Replace("`email`", objCustomer.AppEmailID);
            StrBody = StrBody.Replace("`password`", objEncrypt.Decrypt(objCustomer.AppPassword, appFunctions.strKey.ToString()));

            objCommon.SendConfirmationMail(objCustomer.AppEmailID, strSubject, StrBody, Enums.Enum_Confirmation_Mail_type.register);
            objEncrypt = null;
            objCommon  = null;

            txtEmail.Text = "";
        }
        else
        {
            DInfo.ShowMessage("Invalid email address, Please enter registered email.", Enums.MessageType.Error);
            return(false);
        }
        objCustomer = null;

        return(true);
    }
예제 #27
0
 public ActionResult ActivateDeactivateCustomer()
 {
     try
     {
         int         id      = Convert.ToInt32(Request.Form["id"]);
         int         Flag    = Convert.ToInt32(Request.Form["flag"]);
         tblCustomer newCust = db.tblCustomers.SingleOrDefault(c => c.CustomerID == id);
         newCust.UpdatedDate = DateTime.Now;
         if (Flag >= 1)
         {
             newCust.IsActive = true;
         }
         else
         {
             newCust.IsActive = false;
         }
         db.Entry(newCust).State = EntityState.Modified;
         db.SaveChanges();
         if (Flag >= 1)
         {
             return(Json(new { Act = true, message = "Customer is activated" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(new { DeAct = true, message = "Customer is de-activated" }, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json(new { Error = false, message = "Error!" + ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #28
0
        public static int Insert(Customer customer)
        {
            try
            {
                using (DVDCentralEntities dc = new DVDCentralEntities())
                {
                    tblCustomer tblCustomer = new tblCustomer();

                    tblCustomer.FirstName = customer.FirstName;
                    tblCustomer.LastName  = customer.LastName;
                    tblCustomer.Address   = customer.Address;
                    tblCustomer.City      = customer.City;
                    tblCustomer.State     = customer.State;
                    tblCustomer.ZIP       = customer.ZIP;
                    tblCustomer.UserID    = customer.UserId;
                    tblCustomer.Phone     = customer.Phone;

                    tblCustomer.Id = dc.tblCustomers.Any() ? dc.tblCustomers.Max(dt => dt.Id) + 1 : 1;

                    customer.Id = tblCustomer.Id;

                    dc.tblCustomers.Add(tblCustomer);
                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void Checkout(ShoppingCart cart, User user, int customerId)
        {
            Order order = new Order();

            order.CustomerId = customerId;
            order.OrderDate  = DateTime.Now;
            order.ShipDate   = DateTime.Now;
            using (DVDCentralEntities dc = new DVDCentralEntities())
            {
                tblUser result = (from dt in dc.tblUsers
                                  where user.UserId == dt.UserId
                                  select dt).FirstOrDefault();
                order.UserId = result.Id;

                tblCustomer customer = (from dt in dc.tblCustomers
                                        where order.UserId == dt.UserId
                                        select dt).FirstOrDefault();
                order.CustomerId = customer.Id;
            }

            OrderManager.Insert(order);

            foreach (Movie movie in cart.Items)
            {
                OrderItem item = new OrderItem();
                item.MovieId  = movie.Id;
                item.OrderId  = order.Id;
                item.Quantity = 1;
                item.Cost     = movie.Cost;
                OrderItemManager.Insert(item);
            }
            cart.Checkout();
        }
예제 #30
0
        public static int Delete(int id)
        {
            try
            {
                using (DVDCentralEntities dc = new DVDCentralEntities())
                {
                    //get the row i want to delete
                    tblCustomer deleteRow = (from dt in dc.tblCustomers
                                             where dt.Id == id
                                             select dt).FirstOrDefault();

                    if (deleteRow != null)
                    {
                        dc.tblCustomers.Remove(deleteRow);
                        return(dc.SaveChanges());
                    }
                    else
                    {
                        throw new Exception("Row not found");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public ActionResult CreateSubscriber(SiteSubscriber obj)
 {
     if (ModelState.IsValid)
     {
         Guid guid = new Guid();
         Random rnmd = new Random();
         PinPaymentsDbEntities db = new PinPaymentsDbEntities();
         if (ModelState.IsValid)
         {
             tblCustomer obtbl = new tblCustomer();
             CustomerModel model = new CustomerModel();
             int cutomerid = model.AddCustomer(obj);
             xml = "<subscriber><customer-id>" + cutomerid + "</customer-id><screen-name>" + obj.FirstName + obj.LastName + "</screen-name></subscriber>";
             site = ConfigurationManager.AppSettings["apiUrl"].ToString();
             url = string.Format("https://subs.pinpayments.com/api/v4/{0}/subscribers.xml", site);
             CreateSubscriberApi(url, xml, "Post");
             CardDetail obj1 = new CardDetail();
             obj1.token = GenrateInvoice(obj.SubscriptionId, cutomerid.ToString(), obj.FirstName, obj.Email);
             obj1.firstName = obj.FirstName;
             obj1.lastName = obj.LastName;
             ViewBag.year = DBCommon.BindYear();
             ViewBag.month = DBCommon.BindMonth();
             return RedirectToAction("AddCardDetail", obj1);
         }
         return View("CreateSubscriber");
     }
     else
     {
         return View(obj);
     }
 }