public OperationResultDTO AddCity(City city) { context.City.Add(city); context.SaveChanges(); return(new OperationSuccessDTO <Module> { Message = "Success" }); }
public OperationSuccessDTO <Module> AddModule(Module module) { context.Module.Add(module); context.SaveChanges(); return(new OperationSuccessDTO <Module> { Message = "Success" }); }
public ActionResult Create([Bind(Include = "BookingId,TripId,UserId")] Booking booking) { if (ModelState.IsValid) { db.Bookings.Add(booking); db.SaveChanges(); } //Redirect back to the details page of the trip return(RedirectToAction("Details", "Trips", new { id = booking.TripId })); }
public ActionResult Create([Bind(Include = "TripId,Description")] Trip trip) { if (ModelState.IsValid) { db.Trips.Add(trip); db.SaveChanges(); return(View("Details", trip)); } return(View(trip)); }
public ActionResult Create([Bind(Include = "ExpenseId,Description,Cost,BookingId")] Expense expense) { if (ModelState.IsValid) { db.Expenses.Add(expense); db.SaveChanges(); int tripId = TempData["tripId"] != null ? (int)TempData["tripId"] : 0; return(RedirectToAction("Details", "Trips", new { id = tripId })); } return(View(expense)); }
public bool AddNumber(Numbers number) { _numbers.Add(number); int changes = _context.SaveChanges(); return(changes > 0); }
public OperationResultDTO AddSearchHistory(SearchHistory searchHistory) { context.SearchHistory.Add(searchHistory); context.SaveChanges(); return new OperationSuccessDTO<Module> { Message = "Success" }; }
public OperationResultDTO UpdateTransportCost(string cityName, double transportCost) { var updateCity = context.City.Where(city => city.Name == cityName).FirstOrDefault(); if (updateCity == null) { return(new OperationErrorDTO { Code = 404, Message = $"City with name:{cityName}doesn't exist" }); } updateCity.TransportCost = transportCost; context.SaveChanges(); return(new OperationSuccessDTO <Module> { Message = "Success" }); }
public ActionResult AddCalc(float Operand1, float Operand2, string Operator, float Result) { try { Calculator calcObj = new Calculator(); calcObj.Operand1 = Operand1; calcObj.Operand2 = Operand2; calcObj.Operator = Operator; calcObj.Result = Result; db.Calculators.Add(calcObj); db.SaveChanges(); } catch (Exception ex) { return(Content("Error occured " + ex)); } return(RedirectToAction("CalcPartial")); }
public void AddToQueue(Operation operation) { using (var db = new CalculatorContext(configuration.DbConnectionString)) { var dbOperation = dbOperationMapper.Map(operation); dbOperation.CalculatorId = configuration.CalculatorId; db.Operations.Add(dbOperation); db.SaveChanges(); } }
private CalculatorMemory Modify(Action <CalculatorMemory> action) { CalculatorMemory memory = context.Value.FirstOrDefault() ?? new CalculatorMemory(); action(memory); context.Value.Update(memory); context.SaveChanges(); return(memory); }
public ActionResult AddConvert(string fromUnit, float fromValue, string toUnit, float toValue) { try { Converter convertObj = new Converter { FromUnit = fromUnit, FromValue = fromValue, ToUnit = toUnit, ToValue = toValue }; db.Converters.Add(convertObj); db.SaveChanges(); } catch (Exception ex) { return(Content("Error occured " + ex)); } return(RedirectToAction("Index", "Converter")); }
public void RemoveOperationFromQueueByOperationId(int operationId) { using (var db = new CalculatorContext(configuration.DbConnectionString)) { var dbOperation = db.Operations.FirstOrDefault(x => x.OperationId == operationId); if (dbOperation == null) { return; } db.Operations.Remove(dbOperation); db.SaveChanges(); } }
private void ExecuteSignUpCommandAction() { if (_userRepository.ValidateUserLogin(Login)) { _userRepository.AddUser(Login, Password, Name, Surname); MessageBox.Show("Poprawnie dodano usera"); _context.SaveChanges(); } else { MessageBox.Show("Login zajety"); } }
//public string GetData(int value) //{ // return string.Format("You entered: {0} and I had Changed this", value); //} //public CompositeType GetDataUsingDataContract(CompositeType composite) //{ // if (composite == null) // { // throw new ArgumentNullException("composite"); // } // if (composite.BoolValue) // { // composite.StringValue += "Processed"; // } // return composite; //} public int Add(int a, int b) { int c = a + b; using (CalculatorContext context = new CalculatorContext()) { context.AdditionResults.Add(new Add() { Value1 = a, Value2 = b, Result = c }); context.SaveChanges(); } return(c); }
public bool SaveResult(int type, int input_1, int input_2, int result) { try { CalculatedResult data = new CalculatedResult(); data.MethodTypeId = (MethodType)type; data.Value1 = input_1; data.Value2 = input_2; data.Result = result; _context.CalculatedResults.Add(data); _context.SaveChanges(); return(true); } catch (Exception ex) { throw ex; } }
public void CreateCalculatorResult([FromBody] CalculatorResult calculatorResult) { db.CalculatorResults.Add(calculatorResult); db.SaveChanges(); }
public void Add(OperationResult result) { _context.Results.Add(result); _context.SaveChanges(); }
public ActionResult Index(double?firstNumber, double?secondNumber, string expression) { var computations = new List <Computation>(); using (var db = new CalculatorContext()) { computations.AddRange(db.Computations); } if (firstNumber.HasValue && secondNumber.HasValue) { OperationType type; double result; switch (expression) { case "*": result = firstNumber.Value * secondNumber.Value; type = OperationType.Multiplication; break; case "/": if (secondNumber.Value == 0) { this.ViewBag.Result = "Error"; return(this.View(computations)); } type = OperationType.Divide; result = firstNumber.Value / secondNumber.Value; break; case "+": type = OperationType.Addition; result = firstNumber.Value + secondNumber.Value; break; case "-": type = OperationType.Divison; result = firstNumber.Value - secondNumber.Value; break; default: this.ViewBag.Result = "Error"; return(this.View(computations)); } var host = Dns.GetHostEntry(Dns.GetHostName()); var ip = host.AddressList.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork)?.ToString(); using (var db = new CalculatorContext()) { var computation = new Computation { Date = DateTime.Now, Ip = ip, Operation = type, Result = result }; db.Computations.Add(computation); db.SaveChanges(); } return(RedirectToAction("Index")); } return(this.View(computations)); }