public IHttpActionResult PutCustomerApplication(string id, CustomerApplication customerApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customerApplication.ApplicationID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetCustomerApplication([FromUri] string id)
        {
            CustomerApplication customerApplication = db.CustomerApplications.Find(id);

            if (customerApplication == null)
            {
                return(NotFound());
            }



            return(Ok(customerApplication));
        }
        public IHttpActionResult PostCustomerApplication(CustomerApplication customerApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //Customer cust = db.Customers.Find(customerApplication.EmailID);
            customerApplication.ApplicationID = db.Customers.Find(customerApplication.EmailID).LastName.Substring(0, 3) + db.Customers.Find(customerApplication.EmailID).Contact.Substring(6, 4);
            //customerApplication.Customer.LastName.Substring(0, 3) + customerApplication.Customer.Contact.Substring(6, 4);
            customerApplication.AppointmentDateTentative = DateTime.Now.AddDays(7);
            db.CustomerApplications.Add(customerApplication);
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                if (CustomerApplicationExists(customerApplication.ApplicationID))
                {
                    return(Conflict());
                }
                else
                {
                    throw e;
                }
            }
            TrackStatu ts = new TrackStatu();

            ts.ApplicationID    = db.Customers.Find(customerApplication.EmailID).LastName.Substring(0, 3) + db.Customers.Find(customerApplication.EmailID).Contact.Substring(6, 4);
            ts.Contact          = db.Customers.Find(customerApplication.EmailID).Contact;
            ts.AdminID          = null;
            ts.AppointmentDate  = DateTime.Today.AddDays(7);
            ts.LoanStatus       = "sent for verification";
            ts.LoanApprovalDate = null;
            db.TrackStatus.Add(ts);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = customerApplication.ApplicationID }, customerApplication));
        }
Beispiel #4
0
        public string IsCustomerNameExist(string custName)
        {
            CustomerApplication app = AutofacExt.GetFromFac <CustomerApplication>();

            Infrastructure.Response result = new Infrastructure.Response();
            try
            {
                result.Message = app.IsCustomerNameExist(custName).ToString();
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(JsonHelper.Instance.Serialize(result));
        }
Beispiel #5
0
        public string UserRegister(Customer view)
        {
            CustomerApplication app = AutofacExt.GetFromFac <CustomerApplication>();

            Infrastructure.Response result = new Infrastructure.Response();
            try
            {
                app.Add(view);
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(JsonHelper.Instance.Serialize(result));
        }
        public ActionResult Search(string name, string gender, string city, string region, string purchaseFrom, string purchaseUntil, string classification, string seller)
        {
            LoadDropDownFiltersBag();

            ICustomerRepository customerRepository = new CustomerRepository(_connectionString);
            var customerApp = new CustomerApplication(customerRepository);

            if (Session["userIsAdmin"] != null && !Convert.ToBoolean(Session["userIsAdmin"].ToString()) &&
                Session["userId"] != null)
            {
                seller = Session["userId"].ToString();
            }

            return(View("Index", customerApp
                        .SearchCustomers(name, gender.ToInt32(), city.ToInt32(), region.ToInt32(), purchaseFrom.ToDateTime(), purchaseUntil.ToDateTime(), classification.ToInt32(), seller.ToInt32())
                        .Select(c => CustomerEntityToModel(c))));
        }
 public CustomerController()
 {
     this.customerApplication = new CustomerApplication(new CustomerEfRepository());
 }
        public CustomerApplication GetAppById(string id)
        {
            CustomerApplication customer = db.CustomerApplications.Find(id);

            return(customer);
        }
Beispiel #9
0
 public ValuesController()
 {
     this.customerApplication = new CustomerApplication(new CustomerAdoNetRepository());
 }