private void LogHistory(Customer c) { var h = new CustomerHistory() { Address = c.Address, AddressFound = c.AddressFound, Cell = c.Cell, City = db.Cities.Single(ci => ci.Id == c.CityId).Name, CustomerId = c.Id, Deleted = c.Deleted, Email = c.Email, Home = c.Home, Lat = c.Lat, Lon = c.Lon, Name = c.Name, NoAddress = c.NoAddress, Notes = c.Notes, OtherPhone = c.OtherPhone, PostalCode = c.PostalCode, Restaurant = db.Restaurants.Single(r => r.Id == c.RestaurantId).Name, UpdatedAt = c.UpdatedAt, UpdatedBy = c.UpdatedBy, Work = c.Work }; db.CustomerHistories.Add(h); db.SaveChanges(); }
public ActionResult OrderDetails(int stitchingjobid) { CustomerHistory customerhistory = new CustomerHistory(_context); HistoryItem item = customerhistory.getOrderDetails(stitchingjobid); return(View(item)); }
public virtual List <CustomerHistory> GetList() { List <CustomerHistory> HistoryList = new List <CustomerHistory>(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[@"KIDTEMPLATE"].ConnectionString)) { using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_CustomerHistory_GetList"; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { CustomerHistory ch = new CustomerHistory(); ch.CustomerHistoryID = int.Parse(reader["CustomerHistoryID"].ToString()); ch.CustomerID = int.Parse(reader["CustomerID"].ToString()); ch.Date = DateTime.Parse(reader["Date"].ToString()); ch.WaterUsage = decimal.Parse(reader["WaterUsage"].ToString()); HistoryList.Add(ch); } } } } return(HistoryList); }
public ActionResult UpdateHistory([Bind(Include = "description, id")] CustomerHistory model) { try { string user_id = User.Identity.GetUserId(); CustomerHistory history = db.customer_history.Where(qu => qu.id == model.id).FirstOrDefault(); if (history == null) { return(new HttpStatusCodeResult(404, "Not Found History")); } Customer customer = db.customers.Where(qu => qu.id == history.customer_id).FirstOrDefault(); if (!User.IsInRole("Admin") && customer.user_id != user_id) { return(new HttpStatusCodeResult(403, "Forbidden!")); } history.description = model.description; db.SaveChanges(); return(new HttpStatusCodeResult(200)); } catch (Exception exs) { return(new HttpStatusCodeResult(500, exs.Message.ToString())); } }
public ActionResult AddHistory([Bind(Include = "description, date, customer_id")] CustomerHistory model) { try { string user_id = User.Identity.GetUserId(); Customer customer = db.customers.Where(qu => qu.id == model.customer_id && qu.user_id == user_id).FirstOrDefault(); if (customer == null) { return(new HttpStatusCodeResult(500, "Not permit to customer")); } CustomerHistory q = new CustomerHistory { description = model.description, date = DateTime.Now, customer_id = model.customer_id }; db.customer_history.Add(q); db.SaveChanges(); return(new HttpStatusCodeResult(200)); } catch (Exception exs) { return(new HttpStatusCodeResult(500, exs.Message.ToString())); } }
public CustomerHistory GetCustomerHistoryOverview(WrapperCustomerHistory list) { CustomerHistory history = new CustomerHistory(); for (int i = 0; i < list.ListOfData.Count; i++) { CustomerHistory temp = list.ListOfData.ElementAt(i); if (temp.Type == "InvoiceItem") { // history.RecievableAmount += temp.RecievableAmount; // history.RecievedAmount += temp.RecievedAmount; } else if (temp.Type == "SaleItem") { } else if (temp.Type == "IncomeItem") { history.RecievedAmount += temp.RecievedAmount; } else if (temp.Type == "ExpenseItem") { history.PaidAmount += temp.PaidAmount; } else if (temp.Type == "PayableItem") { history.PayableAmount += temp.PayableAmount; } else if (temp.Type == "RecievableItem") { history.RecievableAmount += temp.RecievableAmount; } } return(history); }
protected void Page_Load(object sender, EventArgs e) { if (Session["person"] != null) { int pK = (int)Session["person"]; int vhId = 0; CustomerName cn = new CustomerName(pK); lblName.Text = cn.CustomerNameFetch(); CustomerHistory ch = new CustomerHistory(pK); lblYear.Text = ch.VehicleYearFetch(); lblMake.Text = ch.VehicleMakeFetch(); vhId = ch.VehicleIdFetch(); AutomartEntities ae = new AutomartEntities(); var servdate = from s in ae.VehicleServiceDetails where s.VehicleService.VehicleID == vhId orderby s.VehicleService.ServiceDate select new {s.VehicleService.ServiceDate, s.AutoService.ServiceName, s.AutoService.ServicePrice }; dlHistory.DataSource = servdate.ToList(); dlHistory.DataBind(); } else { Response.Redirect("Login.aspx"); } }
/// <summary> /// Create New History Record /// </summary> public bool InsertHistory(string licenseId, int childid, int deviceid, string history) { var customerHistory = new CustomerHistory { LicenseId = licenseId, ChildId = childid, DeviceId = deviceid, Obs = string.Empty, History = history, Created = DateTime.UtcNow, Updated = DateTime.UtcNow, Version = "1.0" }; using (var context = new CustomerInfoRepository()) { context.CustomerHistories.Add(customerHistory); try { context.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public ActionResult DeleteHistory(int?id) { string user_id = User.Identity.GetUserId(); try { CustomerHistory s = db.customer_history.Where(src => src.id == id).FirstOrDefault(); Customer c = db.customers.Where(f => f.id == s.customer_id).FirstOrDefault(); if (!User.IsInRole("Admin") && c.user_id != user_id) { return(new HttpStatusCodeResult(403, "Forbidden!")); } if (s == null) { return(new HttpStatusCodeResult(404)); } db.customer_history.Remove(s); db.SaveChanges(); return(new HttpStatusCodeResult(200)); } catch (Exception ex) { return(new HttpStatusCodeResult(500)); throw; } }
public bool EstablishedCustomer() { if (CustomerHistory.Equals(_timeAsCustomer[3]) || CustomerHistory.Equals(_timeAsCustomer[4])) { return(true); } return(false); }
public CustomerHistory InsertCustomerHistory(CustomerHistory customerHistory) { try { _repo.Add(customerHistory); _uow.SaveChanges(); return(customerHistory); } catch (Exception ex) { throw ex; } }
private static CustomerHistory RemoveRefernce(this CustomerHistory item) { var obj = new CustomerHistory(); if (item != null) { obj.Id = item.Id; obj.Date = item.Date; obj.CustomerId = item.CustomerId; obj.IpAddress = item.IpAddress; obj.IsActive = item.IsActive; } return(obj); }
public ActionResult PendingOrders() { if (HttpContext.Session.GetString("Id") == null) { HttpContext.Session.Clear(); return(RedirectToAction("Index", "Account")); } int customerid = Convert.ToInt32(HttpContext.Session.GetString("Id")); //get customer id from session customer id is phone number CustomerHistory customerhistory = new CustomerHistory(_context); List <HistoryItem> historyitems = customerhistory.getPendingOrders(customerid); return(View(historyitems)); }
public async Task <IActionResult> DeleteNote(int id) { string UserName = User.Identity.Name; var findUser = database.Customer.Where(a => a.Login == UserName).FirstOrDefault(); var findActivity = database.CustomerHistory.Where(x => x.MovieId == id && x.CustomerId == findUser.Id).FirstOrDefault(); var deleteNote = new CustomerHistory(); deleteNote.Id = findActivity.Id; deleteNote.Note = ""; database.CustomerHistory.Update(deleteNote); await database.SaveChangesAsync(); return(NoContent()); }
private void SetCurrentCustomerHistory(int historyNum) { try { if (historyNum >= 0 && historyNum < _customerHistoryList.Count()) { _customerHistory = _customerHistoryList[historyNum]; SetHistoryBinding(); _currentHistoryNumList = historyNum; } } catch (Exception ex) { throw ex; } }
private void LoadCustomerHistory(int customerId) { using (IUnitOfWork w = new UnitOfWork()) { Customer customer = GetCustomer(w, customerId); CustomerClass customClass = GetClass(w, customerId); List <CustomerPropertyDto> customerProperties = GetCustomerProperties(w, customerId); List <CustomerPaymentDto> customerPayments = GetCustomerPayments(w, customer); CustomerHistory = new CustomerHistory(); CustomerHistory.CustomerId = customer.CustomerId; CustomerHistory.CustomerName = customer.Name; CustomerHistory.CustomerClass = customClass.Class; CustomerHistory.CustomerProperties = customerProperties; CustomerHistory.CustomerPayments = customerPayments; } }
public static CustomerHistory RemoveReferences(this CustomerHistory item) { var obj = new CustomerHistory(); obj = item.RemoveRefernce(); if (item.Product != null) { obj.Product = new Product(); obj.Product = item.Product.RemoveReference(); } if (item.User != null) { obj.User = new User(); obj.User = item.User.RemoveReference(); } return(obj); }
public async Task <IActionResult> AddToWishlist(int id) { string UserName = User.Identity.Name; var findUser = database.Customer.Where(a => a.Login == UserName).FirstOrDefault(); var findMovie = database.Movie.Where(a => a.Id == id).FirstOrDefault(); var newHistory = new CustomerHistory() { MovieId = findMovie.Id, CustomerId = findUser.Id, StartDate = DateTime.Now, IsBorrowing = false }; database.CustomerHistory.Add(newHistory); await database.SaveChangesAsync(); return(NoContent()); }
public ActionResult HistoryDetail(int id) { string user_id = User.Identity.GetUserId(); CustomerHistory history = db.customer_history.Where(qu => qu.id == id).FirstOrDefault(); Customer customer = db.customers.Where(qu => qu.id == history.customer_id).FirstOrDefault(); if (!User.IsInRole("Admin")) { if (customer.user_id != user_id) { return(new HttpStatusCodeResult(403, "Forbidden!")); } } ViewBag.customer = customer; return(View(history)); }
public async Task <IActionResult> RentMovie([FromBody] int id) { string UserName = User.Identity.Name; var findUser = database.Customer.Where(a => a.Login == UserName).FirstOrDefault(); var findMovie = database.Movie.Where(a => a.Id == id).FirstOrDefault(); if (!(database.CustomerHistory.Any(a => a.MovieId == findMovie.Id) && !(database.CustomerHistory.Any(b => b.CustomerId == findUser.Id)))) { var newHistory = new CustomerHistory() { MovieId = findMovie.Id, CustomerId = findUser.Id, StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(30), IsBorrowing = true }; database.CustomerHistory.Add(newHistory); await database.SaveChangesAsync(); } return(NoContent()); }
public CustomerHistory CustomerHistory([FromBody] custom data) { Models.CustomerHistory customerHistory = new CustomerHistory(); if (data != null) { customerHistory.CustomerId = data.customerId; customerHistory.ProductId = data.ProductId; customerHistory.IpAddress = data.IpAddress; customerHistory.Date = DateTime.Now; customerHistory.IsActive = true; } try { db.CustomerHistories.Add(customerHistory); db.SaveChanges(); return(customerHistory); } catch (Exception ex) { Console.Write(ex); return(customerHistory); } }
internal void ExecuteLoadHistory() { if (!(this.Customer.IsEmptyCustomer() || this.historyLoadedFromAx)) { try { this.history = CS.GetCustomerHistory(this.Customer.CustomerId); } catch (Exception ex) { ApplicationLog.Log( typeof(Customer).ToString(), string.Format("{0}\n{1}", ApplicationLocalizer.Language.Translate(99412), ex.Message), //"an error occured in the operation" LogTraceLevel.Error); CS.InternalApplication.Services.Dialog.ShowMessage(99412, MessageBoxButtons.OK, MessageBoxIcon.Error); } this.historyLoadedFromAx = true; OnPropertyChanged("DateCreated"); OnPropertyChanged("LastVisitedStore"); OnPropertyChanged("LastVisitedDate"); OnPropertyChanged("TotalVisitsCount"); OnPropertyChanged("TotalSalesAmount"); } }
public async void SendSms(int stitchingjobid) { CustomerHistory customerhistory = new CustomerHistory(_context); HistoryItem item = customerhistory.getOrderDetails(stitchingjobid); StitchingJob stitchingjob = _context.StitchingJob.Find(stitchingjobid); Users customer = _context.Users.Find(stitchingjob.CustomerId); string phonenumber = customer.UserId; if (phonenumber[0] == '0') { phonenumber = "+92" + phonenumber.TrimStart(new char[] { '0' }); } string statusname = null; if (item.sj.WarehouseStatus == 1) { int status = -1; foreach (ProductionActivity pa in item.sj.ProductionActivity) { if (status < pa.ProgressStatus) { status = pa.ProgressStatus; } } switch (status) { case 1: statusname = "Cutting کٹنگ"; break; case 2: statusname = "Embroidary کڑھائی"; break; case 3: statusname = "Stitching سلائی"; break; case 4: statusname = "Quality Assurance کوالٹی اشورینس"; break; case 5: statusname = "Packing پیکنگ"; break; case 6: statusname = "Finished تیار"; break; default: break; } } else { statusname = "Warehouse Processing ویئرہاؤس پراسیسنگ"; } string jobname = null; if (item.sj.JobType.JobName == "Kurta") { jobname = "Kurta کرتا"; } else if (item.sj.JobType.JobName == "Shalwar") { jobname = "Shalwar شلوار "; } else if (item.sj.JobType.JobName == "Blazer") { jobname = "Blazer بلیزر"; } else if (item.sj.JobType.JobName == "Suit") { jobname = "Suit سوٹ"; } else if (item.sj.JobType.JobName == "Shirt") { jobname = "Shirt شرٹ"; } else if (item.sj.JobType.JobName == "KameezShalwar") { jobname = "KameezShalwar قمیض شلوار"; } else if (item.sj.JobType.JobName == "Pant") { jobname = "Pant پینٹ"; } string message = "Your order has passed " + statusname + ", " + "Invoice Number انوائس نمبر:" + item.invoice.InvoiceId; /*string ordername = "Order Name آرڈر کا نام:" + jobname + ","; * string invoicenumber = "Invoice Number انوائس نمبر:" + item.invoice.InvoiceId + ","; * string orderdate = "Order Date آرڈر کی تاریخ:" + item.invoice.Date.ToString("dd/MM/yyyy") + ","; * string expecteddate = "Expected Date متوقع تاریخ:" + item.sj.ExpectedDate.Value.ToString("dd/MM/yyyy");*/ using (var client = new HttpClient { BaseAddress = new Uri("https://api.twilio.com") }) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{"AC2371684484ff1369244789f5b99d84cd"}:{"bcb8ebb17ed4d204dcb1c4f9630f030e"}"))); var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("To", phonenumber), new KeyValuePair <string, string>("From", "+12013081067"), new KeyValuePair <string, string>("Body", message) }); try { await client.PostAsync("/2010-04-01/Accounts/AC2371684484ff1369244789f5b99d84cd/Messages.json", content).ConfigureAwait(false); } catch (Exception ex) { } } }
public IList <CustomerHistoryData> GetAllHistory(Guid id) { return(CustomerHistory.ToJavaScriptCustomerHistory(_eventStoreRepository.All(id))); }
private bool historyLoadedFromAx; //Only TRUE if the history has been populated from AX, otherwise history is blank/empty. public CustomerViewModel(ICustomer customer) { this.Customer = customer; this.history = new CustomerHistory(); }
public bool NewCustomer(Customer newCustomer) { try { if (newCustomer == null) { throw new ArgumentNullException("newCustomer"); } using (var db = new HKSupplyContext()) { using (var dbTrans = db.Database.BeginTransaction()) { try { var tmpCustomer = GetCustomerById(newCustomer.IdCustomer); if (tmpCustomer != null) { throw new Exception("Customer already exist"); } newCustomer.IdVer = 1; newCustomer.IdSubVer = 0; newCustomer.Timestamp = DateTime.Now; CustomerHistory customerHistory = (CustomerHistory)newCustomer; db.Customers.Add(newCustomer); db.CustomersHistory.Add(customerHistory); db.SaveChanges(); dbTrans.Commit(); return(true); } catch (SqlException sqlex) { dbTrans.Rollback(); for (int i = 0; i < sqlex.Errors.Count; i++) { _log.Error("Index #" + i + "\n" + "Message: " + sqlex.Errors[i].Message + "\n" + "Error Number: " + sqlex.Errors[i].Number + "\n" + "LineNumber: " + sqlex.Errors[i].LineNumber + "\n" + "Source: " + sqlex.Errors[i].Source + "\n" + "Procedure: " + sqlex.Errors[i].Procedure + "\n"); switch (sqlex.Errors[i].Number) { case -1: //connection broken case -2: //timeout throw new DBServerConnectionException(GlobalSetting.ResManager.GetString("DBServerConnectionError")); } } throw sqlex; } catch (Exception ex) { dbTrans.Rollback(); _log.Error(ex.Message, ex); throw ex; } } } } catch (ArgumentNullException anex) { _log.Error(anex.Message, anex); throw anex; } }
public bool UpdateCustomer(Customer updateCustomer, bool newVer = false) { try { if (updateCustomer == null) { throw new ArgumentNullException("updateCustomer"); } using (var db = new HKSupplyContext()) { using (var dbTrans = db.Database.BeginTransaction()) { try { //var customer = updateCustomer.Clone(); //db.Entry(updateCustomer).State = EntityState.Deleted; //customer.IdSubVer += 1; //if (newVer == true) //{ // customer.IdVer += 1; // customer.IdSubVer = 0; //} //customer.Timestamp = DateTime.Now; //CustomerHistory customerHistory = (CustomerHistory)customer; //db.Customers.Add(customer); //db.CustomersHistory.Add(customerHistory); //db.SaveChanges(); updateCustomer.IdSubVer += 1; if (newVer == true) { updateCustomer.IdVer += 1; updateCustomer.IdSubVer = 0; } updateCustomer.Timestamp = DateTime.Now; CustomerHistory customerHistory = (CustomerHistory)updateCustomer; //Con esto marcaremos todo el objeto como modificado y actualizará todos los campos. //En este caso nos interesa porque la mayoría de los campos de customer se pueden modificar db.Entry(updateCustomer).State = EntityState.Modified; db.CustomersHistory.Add(customerHistory); db.SaveChanges(); dbTrans.Commit(); return(true); } catch (SqlException sqlex) { dbTrans.Rollback(); for (int i = 0; i < sqlex.Errors.Count; i++) { _log.Error("Index #" + i + "\n" + "Message: " + sqlex.Errors[i].Message + "\n" + "Error Number: " + sqlex.Errors[i].Number + "\n" + "LineNumber: " + sqlex.Errors[i].LineNumber + "\n" + "Source: " + sqlex.Errors[i].Source + "\n" + "Procedure: " + sqlex.Errors[i].Procedure + "\n"); switch (sqlex.Errors[i].Number) { case -1: //connection broken case -2: //timeout throw new DBServerConnectionException(GlobalSetting.ResManager.GetString("DBServerConnectionError")); } } throw sqlex; } catch (Exception ex) { dbTrans.Rollback(); _log.Error(ex.Message, ex); throw ex; } } } } catch (ArgumentNullException anex) { _log.Error(anex.Message, anex); throw anex; } }
public async Task <IList <CustomerHistoryData> > GetAllHistory(Guid id) { return(CustomerHistory.ToJavaScriptCustomerHistory(await _eventStoreRepository.All(id))); }
public CustomerHistory AddCustomerHistory(CustomerHistory customerHistory) { return(_customerHistory.Add(customerHistory)); }
private void SeedCustomers(ApplicationDbContext context, string createdByUserId) { _clientCustomers.Add(new List <int>()); //empty, just to have 1 based indexes _clientCustomers.Add(new List <int>()); //clientId 1 _clientCustomers.Add(new List <int>()); //clientId 2 for (int i = 0; i < 10; i++) { var customer = new Customer() { Name = $"Customer {i}", MemberNumber = $"ABC-123-{i}", CreatedByUserId = createdByUserId, CreatedDate = DateTime.UtcNow, Status = Status.Active, }; context.Customers.AddOrUpdate(customer); context.SaveChanges(); var customerHistory = new CustomerHistory() { CustomerId = customer.Id, Name = $"Customer {i}", MemberNumber = $"ABC-123-{i}", ModifiedByUserId = createdByUserId, ModifiedDate = customer.CreatedDate, Status = Status.Active, }; context.CustomersHistory.AddOrUpdate(customerHistory); var customerLocation = new CustomerLocation() { CustomerId = customer.Id, Name = "Head Office Location " + customer.Id, Type = LocationType.HeadOffice, CreatedByUserId = createdByUserId, CreatedDate = customer.CreatedDate, Province = "AB", Country = "Canada", Status = Status.Active, }; context.CustomerLocations.AddOrUpdate(customerLocation); context.SaveChanges(); _customerHeadOffice.Add(customer.Id, customerLocation.Id); var customerLocationHistory = new CustomerLocationHistory() { CustomerLocationId = customerLocation.Id, CustomerId = customer.Id, Name = customerLocation.Name, Type = LocationType.HeadOffice, ModifiedByUserId = createdByUserId, ModifiedDate = customer.CreatedDate, Province = "AB", Country = "Canada", Status = Status.Active, }; context.CustomerLocationsHistory.AddOrUpdate(customerLocationHistory); Random rnd = new Random(); var clientCustomer = new ClientCustomer() { ClientId = rnd.Next(1, 3), CustomerId = customer.Id, CreatedByUserId = createdByUserId, CreatedDate = customer.CreatedDate, Status = Status.Active, }; context.ClientCustomers.AddOrUpdate(clientCustomer); var clientCustomerHistory = new ClientCustomerHistory() { ClientId = rnd.Next(1, 3), CustomerId = customer.Id, ModifiedByUserId = createdByUserId, ModifiedDate = customer.CreatedDate, Status = Status.Active, }; context.ClientCustomersHistory.AddOrUpdate(clientCustomerHistory); context.SaveChanges(); _clientCustomers[clientCustomer.ClientId].Add(customer.Id); } }