コード例 #1
0
        public bool Add(ProyectVm entity)
        {
            try
            {
                var model = new Proyect
                {
                    ApplicationUserId = entity.ApplicationUserId,
                    Title             = entity.Title,
                    Description       = entity.Description,
                    Required_Skill    = entity.Required_Skill,
                    Scope             = entity.Scope,
                    Price             = entity.Price,
                    CategoryId        = entity.CategoryId,
                    CreatedAt         = _datetime
                };
                _dbContext.Add(model);
                _dbContext.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: FileSaver.cs プロジェクト: humbertoms99/TFG
        /// <summary>
        /// Método que guarda las propiedades de un proyecto en un archivo de texto
        /// </summary>
        /// <param name="tw">StreamWriter que escribe en el archivo de texto</param>
        /// <param name="proyect">Proyecto del que se guardan las propiedades</param>
        public void WriteProyectProperties(StreamWriter tw, Proyect proyect, string fileDir)
        {
            tw.WriteLine(DateTime.Now);
            tw.WriteLine(proyect.Name);
            tw.WriteLine(proyect.Description);
            string fileDirectory = fileDir.Split('\\')[fileDir.Split('\\').Length - 1];

            fileDirectory = fileDirectory.Substring(0, fileDirectory.Length - 4);
            if (File.Exists(proyect.ImagePath))
            {
                if (!Directory.Exists(Path.Combine(Application.StartupPath, "Configuraciones\\images", fileDirectory)))
                {
                    Directory.CreateDirectory(Path.Combine(Application.StartupPath, "Configuraciones\\images", fileDirectory));
                }
                string newPath = Path.Combine(Application.StartupPath, "Configuraciones\\images", fileDirectory, Path.GetFileName(proyect.ImagePath));
                if (File.Exists(newPath))
                {
                    string fileName   = Path.GetFileName(proyect.ImagePath);
                    string fileFormat = fileName.Substring(fileName.Length - 4);
                    fileName = fileName.Substring(0, fileName.Length - 4);
                    newPath  = Path.Combine(
                        Application.StartupPath, "Configuraciones\\images",
                        fileDirectory,
                        string.Concat(fileName, "_", (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds, fileFormat)); //Se añade la fecha en timespam
                }
                File.Copy(proyect.ImagePath, newPath);
                proyect.ImagePath = newPath;
            }
            tw.WriteLine(proyect.ImagePath);
        }
コード例 #3
0
        public async Task <IActionResult> Create(ProyectCreateViewModel model)
        {
            var userId = _userManager.GetUserId(User);

            if (userId == null)
            {
                return(BadRequest());
            }

            if (ModelState.IsValid)
            {
                var proyect = new Proyect()
                {
                    Description       = model.Description,
                    Name              = model.Name,
                    Status            = EnumProyectManagment.InProcess,
                    ApplicationUserId = userId,
                };
                _context.Add(proyect);
                _context.Add(new Contributor()
                {
                    Proyect           = proyect,
                    SectionId         = null,
                    ApplicationUserId = userId
                });


                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
コード例 #4
0
        private void GridProyects_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex != -1)
            {
                return;
            }

            string Id = GridProyects.Rows[e.RowIndex].Cells["Id"].Value?.ToString();

            if (string.IsNullOrEmpty(Id))
            {
                return;
            }

            if (MessageBox.Show("¿Desea editar este elemento?", "Editar", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Proyect Proyect = XmlProyect.GetById(Id);

                if (Proyect != null)
                {
                    TxtIdProyecto.Text   = Id;
                    TxtClienteNuevo.Text = Proyect.Customer;
                    TxtNombreNuevo.Text  = Proyect.Name;
                    TxtResponsable.Text  = Proyect.TechnicalLeader;

                    FormUtil.SetFocusFirstInput(GroupNewProyect);
                }
            }

            BtnEliminar.Visible = !string.IsNullOrEmpty(TxtIdProyecto.Text);
        }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "id_Proyect,Code,Name,Status")] Proyect proyect)
 {
     if (ModelState.IsValid)
     {
         db.Entry(proyect).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(proyect));
 }
コード例 #6
0
        public ActionResult Create([Bind(Include = "id_Proyect,Code,Name,Status")] Proyect proyect)
        {
            if (ModelState.IsValid)
            {
                db.Proyects.Add(proyect);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(proyect));
        }
コード例 #7
0
        // GET: Proyects/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Proyect proyect = db.Proyects.Find(id);

            if (proyect == null)
            {
                return(HttpNotFound());
            }
            return(View(proyect));
        }
コード例 #8
0
 public VarValuesForm(Proyect proyect, List <Variable> varsSelected, CultureInfo cultureInfo)
 {
     InitializeComponent();
     _res_man      = new ResourceManager("PlantaPiloto.Resources.Res", typeof(MainForm).Assembly);
     _db_services  = new DB_services(_cul);
     _proyect      = proyect;
     _varsSelected = varsSelected;
     _cul          = cultureInfo;
     _helpProvider = new HelpProvider();
     _filesPath    = GlobalParameters.FilesPath;
     _helpProvider.HelpNamespace = Path.Combine(_filesPath, "helpProyect.chm");
     _exMg           = new ExceptionManagement(_cul);
     _timer          = new System.Timers.Timer(5000);
     _timer.Enabled  = false;
     _timer.Elapsed += new ElapsedEventHandler(this.FillDataGridTimer);
 }
コード例 #9
0
        private Proyect GetFormProyect()
        {
            if (string.IsNullOrWhiteSpace(TxtNombreNuevo.Text))
            {
                MessageBox.Show("Debe ingresar un nombre de proyecto.", "No válido.");
                return(null);
            }

            Proyect Proyect = new Proyect(
                string.IsNullOrEmpty(TxtIdProyecto.Text) ? Guid.NewGuid().ToString() : TxtIdProyecto.Text,
                TxtNombreNuevo.Text,
                TxtClienteNuevo.Text,
                TxtResponsable.Text
                );

            return(Proyect);
        }