private static void Main(string[] args)
        {
            var db = new DB("Bandit skolen", new List <Student>(), new List <Employee>(), new List <Team>());

            db.Add("Banditterne", "Undervisning i kagesmagning");
            db.Add("benny", 22.50m, false);
            db.Add("Lars", 12);


            var s = db.findStudent("Lars");
            var e = db.findEmployee("benny");

            Console.WriteLine(e.getName());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("IdVentaRequisito,IdVentaContratacion,IdBeneficiario,IdDocumentoRespaldo,IdDocumentoFormato,DocumentoEntregado,PathArchivo,ArchivoCargado,IdEstadoRegistro,IdUsuario,FechaRegistro")] VentaRequisito ventaRequisito, IFormFile ArchivoPDF, int?id, string Cities)
        {
            if (ModelState.IsValid)
            {
                String fileName = "";
                if (ArchivoPDF != null)
                {
                    fileName = Path.Combine(he.WebRootPath, Path.GetFileName(ArchivoPDF.FileName));
                    ArchivoPDF.CopyTo(new FileStream(fileName, FileMode.Create));
                }

                ventaRequisito.IdVentaContratacion = Convert.ToInt32(TempData["IdContratacion"]);
                ventaRequisito.IdVentaContratacion = Convert.ToInt32(id);
                ventaRequisito.IdBeneficiario      = 1;
                ventaRequisito.DocumentoEntregado  = true;
                ventaRequisito.IdDocumentoRespaldo = 1; Convert.ToInt32(Cities);
                ventaRequisito.PathArchivo         = fileName;
                ventaRequisito.ArchivoCargado      = true;
                ventaRequisito.IdEstadoRegistro    = 1;
                ventaRequisito.IdUsuario           = 1;
                ventaRequisito.FechaRegistro       = DateTime.Now;

                DB.Add(ventaRequisito);
                await DB.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ventaRequisito));
        }
        public async Task <IActionResult> Create(Models.Planificacion.OrganismoFinanciador item)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser currentUser = await GetCurrentUser();

                item.IdUsuario = currentUser.AspNetUserId;
                item.Gestion   = Convert.ToString(DateTime.Now.Year);
                // item.Gestion = "2019";
                item.IdBeneficiario     = 0;
                item.IdPais             = 1;
                item.CargoRepresentante = "-";
                item.IdEstadoRegistro   = 1;
                item.FechaRegistro      = DateTime.Now;
                DB.Add(item);
                await DB.SaveChangesAsync();

                SetFlashSuccess("Registro creado satisfactoriamente");
            }
            var items = DB.FuenteFinanciamiento.
                        Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.FuenteFinanciamiento = items;

            return(PartialView("Create", item));
        }
Exemplo n.º 4
0
        public async Task <JsonResult> CreateNewGoal(string exercise, double quantity, string unitsType, DateTime?completionDate)
        {
            Exercise e = await _context.Exercise
                         .FromSqlInterpolated($"SELECT * FROM Exercise WHERE Name={exercise}")
                         .FirstOrDefaultAsync();

            // If the user doesn't provide a deadline, make the completion date null.
            //   Otherwise, the DateTime class will automatically parse "" into January 1, 2001
            if (completionDate.Equals(""))
            {
                completionDate = null;
            }

            Goal g = new Goal()
            {
                Exercise            = e,
                ExerciseID          = e.ExerciseID,
                MeasurementQuantity = quantity,
                MeasurementType     = unitsType,
                UserID   = User.Claims.First().Value,
                Deadline = completionDate
            };

            _context.Add(g);
            await _context.SaveChangesAsync();

            return(Json(new
            {
                success = false
            }));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create(Models.Ventas.DocumentoRespaldo item)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser currentUser = await GetCurrentUser();

                item.IdUsuario        = currentUser.AspNetUserId;
                item.IdEstadoRegistro = 1;
                item.FechaRegistro    = DateTime.Now;
                //item.IdProceso=0;
                DB.Add(item);
                await DB.SaveChangesAsync();

                SetFlashSuccess("Registro creado satisfactoriamente");
            }
            var items1 = DB.DocumentoClasificacion.
                         Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.DocumentoClasificacion = items1;
            var items2 = DB.FrecuenciaUso.
                         Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.FrecuenciaUso = items2;
            var items3 = DB.DocumentoFormato.
                         Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.DocumentoFormato = items3;
            return(PartialView("Create", item));
        }
Exemplo n.º 6
0
        public IActionResult Salvar(EventoDTO eventoFormulario)
        {
            if (eventoFormulario.Id == 0)
            {
                //Registro novo
                var eventoBD = new Evento();

                eventoBD.Titulo = eventoFormulario.Titulo;
                eventoBD.Data   = eventoFormulario.Data;

                _dbInterno.Add(eventoBD);
            }
            else
            {
                //Registro atualizado
                var eventoBD = _dbInterno.Eventos.SingleOrDefault(e => e.Id == eventoFormulario.Id);

                eventoBD.Titulo = eventoFormulario.Titulo;
                eventoBD.Data   = eventoFormulario.Data;

                _dbInterno.Update(eventoBD);
            }

            _dbInterno.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create(Models.Finanzas.CuentaBancaria item)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser currentUser = await GetCurrentUser();

                item.IdUsuario        = currentUser.AspNetUserId;
                item.IdEstadoRegistro = 1;
                item.FechaRegistro    = DateTime.Now;
                DB.Add(item);
                await DB.SaveChangesAsync();

                SetFlashSuccess("Registro creado satisfactoriamente");
            }
            var items1 = DB.Banco.
                         Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.Banco = items1;

            var items2 = DB.TipoCuentaBanco.
                         Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.TipoCuentaBanco = items2;

            var items3 = DB.TipoMoneda.
                         Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.TipoMoneda = items3;

            var items4 = DB.OrganismoFinanciador.
                         Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.OrganismoFinanciador = items4;
            return(PartialView("Create", item));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create(HojaRutaDTO item)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser currentUser = await GetCurrentUser();

                string cite = await GetCite(item.UnidadEjecutoraId);

                HojaRuta hojaRuta = item.prepare(currentUser.AspNetUserId, DB);
                hojaRuta.CiteUE = $"{cite}-CORR.".Replace("NN-", "");
                DB.Add(hojaRuta);
                await DB.SaveChangesAsync();

                var parent = hojaRuta.Derivaciones.First(d => d.Padre == -1);

                if (parent != null)
                {
                    foreach (var child in hojaRuta.Derivaciones.Where(d => d.Padre == 0))
                    {
                        child.Padre = parent.Id;
                    }

                    parent.Padre = 0;
                    DB.SaveChanges();
                }

                SetFlashSuccess("La Hoja de Ruta fue creada correctamente");
                return(RedirectToAction(nameof(Index), new{ type = Constantes.HRTipoDespachados }));
            }
            return(View("_Create", item));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Create(Documento item)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser currentUser = await GetCurrentUser();

                string cite = await GetCite(item.AreaFuncionarioOrigenId);

                item.IdUsuario        = currentUser.AspNetUserId;
                item.Cite             = cite;
                item.FechaRegistro    = DateTime.Now;
                item.IdEstadoRegistro = Constantes.Registrado;
                DB.Add(item);
                await DB.SaveChangesAsync();
            }
            if (item.Id > 0 && item.Redirect != null)
            {
                ViewBag.redirect = item.Redirect;
                if (item.Redirect == HojasRutaInternaController.RedirectHRSent && item.hojaRutaDetalleId > 0)
                {
                    ViewBag.redirect = @Url.Action("Derivar", "HojasRutaInterna",
                                                   new { area = "Correspondencia", id = item.hojaRutaDetalleId, idDoc = item.Id });
                }
                else if (item.Redirect == HojasRutaInternaController.RedirectHRCreate)
                {
                    ViewBag.redirect = @Url.Action("create", "HojasRutaInterna", new { area = "Correspondencia", idDoc = item.Id });
                }

                return(PartialView("_Redirect"));
            }

            return(PartialView("_Create", item));
        }
Exemplo n.º 10
0
 // INDSÆT NY RESERVATION
 public void Insert(Reservation res)
 {
     lock (_lockKey)
     {
         DB.Add(res);
     }
 }
Exemplo n.º 11
0
        public async Task <IActionResult> Create(Models.RRHH.UnidadEjecutora item)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser currentUser = await GetCurrentUser();

                item.IdUsuario = currentUser.AspNetUserId;
                item.IdUnidadEjecutoraPadre = 0;
                item.Nivel            = 0;
                item.EsUltimoNivel    = false;
                item.Gestion          = "2019";
                item.MontoLimite      = 0;
                item.CantidadLimite   = 0;
                item.IdEstadoRegistro = 1;
                item.FechaRegistro    = DateTime.Now;
                DB.Add(item);
                await DB.SaveChangesAsync();

                SetFlashSuccess("Registro creado satisfactoriamente");
            }
            //Municipio
            var items = DB.Municipio.
                        Where(i => i.IdEstadoRegistro != Constantes.Anulado).OrderBy(i => i.Descripcion).ToList();

            ViewBag.Municipio = items;

            return(PartialView("Create", item));
        }
Exemplo n.º 12
0
        private void CreatePin(Image pin, string type)
        {
            Button button = new Button();// { Style = FindResource("PinStyle") as Style };

            button.Click      += new RoutedEventHandler(Click_Pin);
            button.MouseEnter += new MouseEventHandler(Mouse_Enter);
            button.MouseLeave += new MouseEventHandler(Mouse_Leave);
            button.PreviewMouseRightButtonDown += new MouseButtonEventHandler(Right_Click_Pin);
            button.Background      = Brushes.Transparent;
            button.BorderThickness = new Thickness(0);



            Pin dbPin = new Pin();

            dbPin.pin_title     = "Untitled";
            dbPin.pin_content   = "";
            dbPin.pin_x         = rightClickPoint.X;
            dbPin.pin_y         = rightClickPoint.Y;
            dbPin.parent_map_id = currentMap.map_id;
            dbPin.pin_type      = type;
            DB.Add(dbPin);

            button.Name    = "id" + DB.getPins().Last().pin_id;
            button.Content = pin;

            pins.Add(button);
            ResizePins();

            pinCanvas.Children.Add(button);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 添加新的PasswordItem
        /// </summary>
        /// <param name="title"></param>
        /// <param name="img"></param>
        /// <param name="urlstr"></param>
        /// <param name="account"></param>
        /// <param name="password"></param>
        public void AddPasswordItem(string title, Byte[] img, string urlstr, string account, string password)
        {
            PasswordItem newItem = new PasswordItem(title, img, urlstr, account, password);

            this.allItems.Add(newItem);
            DB.Add(newItem);
        }
Exemplo n.º 14
0
        public async Task <JsonResult> CreateNewExerciseRecord(string exercise, double?weightQuantity, double?distanceQuantity, double?timeQuantity, double?repsQuantity, DateTime submitDate)
        {
            Exercise e = await _context.Exercise
                         .FromSqlInterpolated($"SELECT * FROM Exercise WHERE Name={exercise}")
                         .FirstOrDefaultAsync();

            ExerciseRecord er = new ExerciseRecord()
            {
                Exercise         = e,
                ExcerciseID      = e.ExerciseID,
                UserID           = User.Claims.First().Value,
                WeightQuantity   = weightQuantity,
                DistanceQuantity = distanceQuantity,
                TimeQuantity     = timeQuantity,
                RepQuantity      = repsQuantity,
                SubmitDate       = submitDate
            };

            _context.Add(er);
            await _context.SaveChangesAsync();

            return(Json(new
            {
                success = false
            }));
        }
Exemplo n.º 15
0
        private void BtnAddCategory(object sender, RoutedEventArgs e)
        {
            NoteCategory nc = new NoteCategory();

            nc.category_parent = 1;
            nc.category_title  = "New Category";
            DB.Add(nc);
            UpdateNotes();
        }
Exemplo n.º 16
0
        private void CreateNewCategoryClick(object sender, RoutedEventArgs e)
        {
            NoteCategory nc = new NoteCategory();

            nc.category_title  = "New Category";
            nc.category_parent = id;
            DB.Add(nc);
            UpdateNotes();
        }
Exemplo n.º 17
0
        public Endereco Adicionar(Endereco Endereco)
        {
            DB.Add(Insert, GetParam(Endereco));

            int id = ObterUltimoId();

            Endereco.Id = id;

            return(Endereco);
        }
Exemplo n.º 18
0
        public Teste Adicionar(Teste Teste)
        {
            DB.Add(sqlInsertTeste, GetParam(Teste));

            int id = ObterUltimoId();

            Teste.Id = id;

            return(Teste);
        }
Exemplo n.º 19
0
        public ContaDominio Adicionar(ContaDominio ContaDominio)
        {
            DB.Add(Insert, GetParam(ContaDominio));

            int id = ObterUltimoId();

            ContaDominio.Id = id;

            return(ContaDominio);
        }
Exemplo n.º 20
0
        public ActionResult Upload(HttpPostedFileBase image, string text)
        {
            string fileName = Guid.NewGuid() + Path.GetExtension(image.FileName);

            image.SaveAs(Server.MapPath("~/Images") + "/" + fileName);
            DB db = new DB();

            db.Add(text, fileName);
            return(Redirect("/home/index"));
        }
Exemplo n.º 21
0
        private void Create_Map_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Created a map");

            Image       map    = new Image();
            BitmapImage bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.UriSource = new Uri("Assets/Pins/map.png", UriKind.Relative);
            bitmap.EndInit();
            map.Source  = bitmap;
            map.Stretch = Stretch.UniformToFill;

            Button button = new Button();// { Style = FindResource("PinStyle") as Style };

            //button.Click += new RoutedEventHandler(Click_Map);
            button.PreviewMouseLeftButtonDown  += new MouseButtonEventHandler(Click_Map);
            button.PreviewMouseRightButtonDown += new MouseButtonEventHandler(Right_Click_Map);
            button.MouseEnter     += new MouseEventHandler(Mouse_Enter);
            button.MouseLeave     += new MouseEventHandler(Mouse_Leave);
            button.Background      = Brushes.Transparent;
            button.BorderThickness = new Thickness(0);

            Map dbMap = new Map();

            dbMap.map_name      = "Untitled";
            dbMap.map_x         = rightClickPoint.X;
            dbMap.map_y         = rightClickPoint.Y;
            dbMap.parent_map_id = currentMap.map_id;

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title           = "Select a Map Image File";
            openFileDialog.CheckFileExists = true;
            openFileDialog.CheckPathExists = true;
            openFileDialog.ReadOnlyChecked = true;
            openFileDialog.ShowReadOnly    = true;
            openFileDialog.Filter          = "Image files (*.png;*.jpeg)|*.png;*.jpeg|All files (*.*)|*.*";
            var result = openFileDialog.ShowDialog();

            if (openFileDialog.FileName != "")
            {
                byte[] buffer = File.ReadAllBytes(openFileDialog.FileName);
                dbMap.map_file = buffer;
                dbMap.map_name = System.IO.Path.GetFileNameWithoutExtension(openFileDialog.FileName);
                DB.Add(dbMap);
                button.Name    = "mid" + DB.GetMaps().Last().map_id;
                button.Content = map;

                maps.Add(button);

                pinCanvas.Children.Add(button);
                ResizePins();
            }
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Create(Models.RRHHParam.TipoBeneficiario tipoBeneficiario)
        {
            if (ModelState.IsValid)
            {
                DB.Add(tipoBeneficiario);
                await DB.SaveChangesAsync();

                SetFlashSuccess("Registro creado satisfactoriamente");
            }
            return(PartialView("_Create", tipoBeneficiario));
        }
Exemplo n.º 23
0
        public async Task <IActionResult> Create([Bind("Name,Description,Price,InStock,Id")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <IActionResult> Create([Bind("Name,Description,Id")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Exemplo n.º 25
0
        public int Add(User obj)
        {
            string username      = obj.username;
            short  account_type  = obj.account_type;
            string password_hash = obj.password_hash;
            string password_salt = obj.password_salt;
            string com           = "('" + username + "', '" + account_type + "', '" + password_hash + "', '" + password_salt + "')";

            DataContext.Add("users", com);
            return(0);
        }
Exemplo n.º 26
0
 public void SaveProduct(Product product)
 {
     if (product.Id == 0)
     {
         db.Add(product);
     }
     else
     {
         db.UpdateProduct(product);
     }
 }
Exemplo n.º 27
0
        public int Add(Timetable obj)
        {
            string      UserId      = obj.UserId;
            string      TimetableId = obj.TimetableId;
            string      name        = obj.name;
            List <Time> TimeOfFeed  = obj.TimeOfFeed;
            string      com         = "('" + TimetableId + "', '" + UserId + "', '" + name + "')";

            if (TimeOfFeed != null)
            {
                foreach (Time t in TimeOfFeed)
                {
                    string com_2 = "('" + t.TimeHMS + "', '" + TimetableId + "')";
                    string com_3 = "(time, timetable_id)";
                    DataContext.Add("timestamps", com_2, com_3);
                }
            }
            DataContext.Add("timetable", com);
            return(0);
        }
Exemplo n.º 28
0
        private void BtnAddNote(object sender, RoutedEventArgs e)
        {
            Note   note    = new Note();
            string rtfText = "{\\rtf1\\ansi\\ansicpg1252\\uc1\\htmautsp\\deff2{\\fonttbl{\\f0\\fcharset0 Times New Roman;}{\\f2\\fcharset0 Segoe UI;}}{\\colortbl\\red0\\green0\\blue0;\\red255\\green255\\blue255;}\\loch\\hich\\dbch\\pard\\plain\\ltrpar\\itap0{\\lang1033\\fs18\\f2\\cf0 \\cf0\\ql{\\f2 \\li0\\ri0\\sa0\\sb0\\fi0\\ql\\par}}}";

            note.note_title   = "New Note";
            note.category_id  = 1;
            note.note_content = rtfText;
            DB.Add(note);
            UpdateNotes();
        }
Exemplo n.º 29
0
        public int Add(Feeder obj)
        {
            string User_id      = obj.User_id;
            string Feeder_id    = obj.Feeder_id;
            string Timetable_id = obj.Timetable_id;
            string Name         = obj.Name;
            string com          = "('" + Feeder_id + "', '" + User_id + "', '" + Timetable_id + "', '" + Name + "')";

            DataContext.Add("feeders", com);
            return(0);
        }
Exemplo n.º 30
0
 public async Task<IActionResult> Create([Bind("idSkoleni,nazev,popis,skolitel")] Models.PSkoleni skoleni)
 {
     ViewData["adminVolba"] = 3;
     if (ModelState.IsValid)
     {
         _context.Add(skoleni);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(skoleni);
 }