//public HttpResponseMessage Register(string Email, string password, string Name, string PhoneNumber, string username, // string Address, string CardType, string BankName, string AccountNumber, string IFSCCode) public HttpResponseMessage Registertest([FromBody] regandlogin ub) { project1Entities db = new project1Entities(); UserTable tabledata = new UserTable(); var emailAlreadyExists = db.UserTables.Find(ub.Email); if (emailAlreadyExists != null) { return(Request.CreateResponse(HttpStatusCode.OK, "Already Exists!")); } tabledata.Email = ub.Email; tabledata.password = ub.password; tabledata.Name = ub.Name; tabledata.PhoneNumber = ub.PhoneNumber; tabledata.username = ub.username; tabledata.validation = ub.validation; tabledata.Address = ub.Address; tabledata.CardType = ub.CardType; db.UserTables.Add(tabledata); db.SaveChanges(); BankDetail data = new BankDetail(); data.Email = ub.Email; data.BankName = ub.BankName; data.AccountNumber = ub.AccountNumber; data.IFSCCode = ub.IFSCCode; db.BankDetails.Add(data); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, ub)); }
public IHttpActionResult PutProduct(int id, Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductID) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "reg_id,users_name,user_f_name,user_email,user_cnic,user_reg_date,user_phonenum,gender,user_address,user_status,user_hecPercentage,yearofpassingexam,userdep_id,userdep_id1")] user_register user_register) { if (ModelState.IsValid) { db.user_register.Add(user_register); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.userdep_id = new SelectList(db.departments, "dep_id", "dep_name", user_register.userdep_id); ViewBag.userdep_id1 = new SelectList(db.department1, "dep_id1", "dep_name1", user_register.userdep_id1); return(View(user_register)); }
public HttpResponseMessage PutFinance(int FinanceID, [FromBody] Finance finance) { try { using (project1Entities db = new project1Entities()) { var data = db.Finances.Find(FinanceID); if (data == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Purchase with finance id " + FinanceID + "not found")); } else { data.Email = finance.Email; data.Months = finance.Months; data.EmiAmount = finance.EmiAmount; data.TotalAmount = finance.TotalAmount; data.RemainingAmount = finance.RemainingAmount; data.purchaseDate = finance.purchaseDate; data.ProductID = finance.ProductID; data.LastPaymentDate = finance.LastPaymentDate; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage PostFinance(string Email, int ProductID, [FromBody] Finance finance) { try { using (project1Entities db = new project1Entities()) { var limit = db.CardDetails.Where(cd => cd.Email == Email).FirstOrDefault(); var price = db.Products.Where(pr => pr.ProductID == ProductID).FirstOrDefault(); if (limit.CurrentLimit > price.Price) { limit.CurrentLimit = limit.CurrentLimit - price.Price; finance.purchaseDate = DateTime.Now; db.Finances.Add(finance); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, finance)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotAcceptable, "Finance id cannot be created due to low current limit")); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage financeup(int id) { try { using (project1Entities db = new project1Entities()) { var data = db.Finances.Find(id); CardDetail card = db.CardDetails.Where(x => x.Email == data.Email).FirstOrDefault(); if (data == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Purchase with finance id " + id + " not found")); } else { data.Months = data.Months - 1; //data.EmiAmount = finance.EmiAmount; //data.TotalAmount = finance.TotalAmount; data.RemainingAmount = data.RemainingAmount - data.EmiAmount; //data.purchaseDate = finance.purchaseDate; //data.ProductID = finance.ProductID; data.LastPaymentDate = DateTime.Now; card.CurrentLimit = card.CurrentLimit + data.EmiAmount; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public ActionResult register(registerviewmodel uvm) { List <department> list1 = db.departments.ToList(); ViewBag.list = new SelectList(list1, "dep_id", "dep_name"); List <department1> list2 = db.department1.ToList(); ViewBag.list1 = new SelectList(list2, "dep_id1", "dep_name1"); user_register us = new user_register(); us.users_name = uvm.users_name; us.user_f_name = uvm.user_f_name; us.user_email = uvm.user_email; us.user_cnic = uvm.user_cnic; us.user_reg_date = uvm.user_reg_date; us.user_phonenum = uvm.user_phonenum; us.gender = uvm.gender; us.user_address = uvm.user_address; us.user_hecPercentage = uvm.user_hecPercentage; us.yearofpassingexam = uvm.yearofpassingexam; us.userdep_id = uvm.userdep_id; us.userdep_id1 = uvm.userdep_id1; us.dep_name = uvm.dep_name; us.dep_name1 = uvm.dep_name1; us.user_status = 0; db.user_register.Add(us); db.SaveChanges(); Session["user"] = us.users_name; return(RedirectToAction("optional")); }
public HttpResponseMessage Approved(string Email) { try { using (project1Entities db = new project1Entities()) { UserTable user = db.UserTables.Find(Email); CardType type = db.CardTypes.Find(user.CardType); Random rnd = new Random(); if (user == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "User with Email " + Email + "not found")); } DateTime d1 = DateTime.Now; user.validation = "Approved"; CardDetail card = new CardDetail(); card.Type = user.CardType; card.Email = user.Email; card.CurrentLimit = type.Limit; card.ValidFrom = d1; card.ValidTill = d1.AddYears(4); card.CVV = rnd.Next(101, 999); db.CardDetails.Add(card); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, user)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage ChangePassword(string email, string phonenumber, string pwd) { try { project1Entities db = new project1Entities(); UserTable ut = new UserTable(); var data = db.UserTables.Find(email); if (data == null) { return(Request.CreateResponse(HttpStatusCode.OK, "Account with given email is not found")); } else { if (data.PhoneNumber == phonenumber) { data.password = pwd; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Password Changed!")); } else { return(Request.CreateResponse(HttpStatusCode.OK, "Phone number is wrong")); } } } catch (Exception) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Please try again!")); } }
// PUT: api/Products/5 //[ResponseType(typeof(void))] public HttpResponseMessage PutProduct(int id, Product product) { try { var data = db.Products.Find(id); if (data == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Product with id" + id + "not found")); } data.ProductName = product.ProductName; data.ImageName = product.ImageName; data.stock = product.stock; data.Price = product.Price; data.ProductDetails = product.ProductDetails; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage PostFinance([FromBody] Finance finance) { try { using (project1Entities db = new project1Entities()) { db.Finances.Add(finance); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, finance)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Rejected(string Email) { try { using (project1Entities db = new project1Entities()) { UserTable user = db.UserTables.Find(Email); user.validation = "Rejected"; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created, user)); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage DeleteFinance(int FinanceId) { try { using (project1Entities db = new project1Entities()) { var data = db.Finances.Find(FinanceId); if (data == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, "Purchase with finance id" + FinanceId + "not found")); } else { db.Finances.Remove(data); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }