Exemplo n.º 1
0
        public virtual int CreateNewTreeDetail(TreeDetail newTreeDetail)
        {
            // Validate Parameters
            if (newTreeDetail == null)
            {
                throw (new ArgumentNullException("newTreeDetail"));
            }

            // Apply business rules
            OnTreeDetailSaving(newTreeDetail);
            OnTreeDetailCreating(newTreeDetail);

            _DatabaseContext.TreeDetails.AddObject(newTreeDetail);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No treeDetail created!");
            }

            // Apply business workflow
            OnTreeDetailCreated(newTreeDetail);
            OnTreeDetailSaved(newTreeDetail);

            return(newTreeDetail.TreeDetailsID);
        }
Exemplo n.º 2
0
        public void DeleteTreeDetails(List <int> treeDetailsIDsToDelete)
        {
            //Validate Input
            foreach (int treeDetailsID in treeDetailsIDsToDelete)
            {
                if (treeDetailsID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("TreeDetailsID");
                }
            }

            List <TreeDetail> treeDetailsToBeDeleted = new List <TreeDetail>();

            foreach (int treeDetailsID in treeDetailsIDsToDelete)
            {
                TreeDetail treeDetail = new TreeDetail {
                    TreeDetailsID = treeDetailsID
                };
                _DatabaseContext.TreeDetails.Attach(treeDetail);
                _DatabaseContext.TreeDetails.DeleteObject(treeDetail);
                treeDetailsToBeDeleted.Add(treeDetail);
                OnTreeDetailDeleting(treeDetail);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != treeDetailsIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more treeDetail records have not been deleted.");
            }
            foreach (TreeDetail treeDetailToBeDeleted in treeDetailsToBeDeleted)
            {
                OnTreeDetailDeleted(treeDetailToBeDeleted);
            }
        }
Exemplo n.º 3
0
        public void DeleteTreeDetail(TreeDetail treeDetailToBeDeleted)
        {
            //Validate Input
            if (treeDetailToBeDeleted == null)
            {
                throw (new ArgumentNullException("treeDetailToBeDeleted"));
            }

            // Validate Primary key value
            if (treeDetailToBeDeleted.TreeDetailsID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("TreeDetailsID");
            }

            OnTreeDetailSaving(treeDetailToBeDeleted);
            OnTreeDetailDeleting(treeDetailToBeDeleted);

            if (treeDetailToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.TreeDetails.Attach(treeDetailToBeDeleted);
            }
            _DatabaseContext.TreeDetails.DeleteObject(treeDetailToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No TreeDetail deleted!");
            }

            OnTreeDetailDeleted(treeDetailToBeDeleted);
            OnTreeDetailSaved(treeDetailToBeDeleted);
        }
Exemplo n.º 4
0
        public void UpdateTreeDetail(TreeDetail updatedTreeDetail)
        {
            // Validate Parameters
            if (updatedTreeDetail == null)
            {
                throw (new ArgumentNullException("updatedTreeDetail"));
            }

            // Validate Primary key value
            if (updatedTreeDetail.TreeDetailsID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("TreeDetailsID");
            }

            // Apply business rules
            OnTreeDetailSaving(updatedTreeDetail);
            OnTreeDetailUpdating(updatedTreeDetail);

            //attaching and making ready for parsistance
            if (updatedTreeDetail.EntityState == EntityState.Detached)
            {
                _DatabaseContext.TreeDetails.Attach(updatedTreeDetail);
            }
            _DatabaseContext.ObjectStateManager.ChangeObjectState(updatedTreeDetail, System.Data.EntityState.Modified);            //this line makes the code un-testable!
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No treeDetail updated!");
            }

            //Apply business workflow
            OnTreeDetailUpdated(updatedTreeDetail);
            OnTreeDetailSaved(updatedTreeDetail);
        }
Exemplo n.º 5
0
    public static void AddTreeToAutoCADImportFile(Project_Organisms project_Organism, string path)
    {
        try
        {
            TreeDetail treeDetail = project_Organism.TreeDetails.First();

            string toWrite =
                treeDetail.Number
                + ","
                + String.Format("{0:0.####################################}", treeDetail.Y)
                + ","
                + String.Format("{0:0.####################################}", treeDetail.X)
                + ",0,"
                + project_Organism.Organism.CommonName.CommonNameDesc;

            using (StreamWriter writer = new StreamWriter(path, true))
            {
                writer.WriteLine(toWrite);
                writer.Flush();
                writer.Close();
            }
        }
        catch (Exception ex)
        {
            throw new Exception("Error on AddTree method: " + ex.Message);
        }
    }
Exemplo n.º 6
0
        public static object GetProjectOrganismObject(TreeDetail treeDetail)
        {
            var daps = treeDetail.Daps.Select(i => new { DapValue = i.DapValue });

            JObject jo = JObject.FromObject(new
            {
                Daps = daps
            }
                                            );

            string Daps = jo.ToString();

            var tree = new
            {
                treeDetail.ActionProposed.ActionProposedDesc,
                treeDetail.ActionProposed.ActionProposedID,
                treeDetail.ActionProposed.Color.ColorDesc,
                treeDetail.ActionProposed.Color.ColorID,
                treeDetail.ActionProposed.Color.Code,
                treeDetail.Commentary,
                treeDetail.Condition.ConditionDesc,
                treeDetail.Condition.ConditionID,
                treeDetail.CreatedDate,
                treeDetail.CreatorUserID,
                treeDetail.Dap,
                treeDetail.Dap_Counter,
                Daps,//jsonSerialiser.Serialize(treeDetail.Daps.ToList()),
                treeDetail.EditedDate,
                treeDetail.EditorUserID,
                treeDetail.Height,
                treeDetail.Lat,
                treeDetail.Lon,
                treeDetail.X,
                treeDetail.Y,
                treeDetail.Number,
                treeDetail.ProjectOrganismID,
                treeDetail.Project_Organisms.ProjectID,
                treeDetail.Project_Organisms.OrganismID,
                treeDetail.Project_Organisms.Organism.CommonName.CommonNameDesc,
                treeDetail.Project_Organisms.Organism.CommonName.CommonNameID,
                treeDetail.Project_Organisms.Organism.ScientificName.ScientificNameDesc,
                treeDetail.Project_Organisms.Organism.ScientificName.ScientificNameID,
                treeDetail.TreeDetailsID,
                treeDetail.Varas
            };

            return(tree);
        }
Exemplo n.º 7
0
    protected string getTrees()
    {
        List <Project_Organisms> project_Organisms = new Project_OrganismsBLL().GetProject_OrganismsByProjectID(Convert.ToInt32(RouteData.Values["project_id"]));

        List <object> trees = new List <object>();

        foreach (Project_Organisms project_Organism in project_Organisms)
        {
            TreeDetail treeDetail = project_Organism.TreeDetails.ToList()[0];
            var        tree       = new
            {
                treeDetail.ActionProposed.ActionProposedDesc,
                treeDetail.ActionProposed.ActionProposedID,
                treeDetail.ActionProposed.Color.ColorDesc,
                treeDetail.ActionProposed.Color.ColorID,
                treeDetail.ActionProposed.Color.Code,
                treeDetail.MaritimeZone,
                treeDetail.Littoral,
                treeDetail.Commentary,
                treeDetail.Condition.ConditionDesc,
                treeDetail.Condition.ConditionID,
                treeDetail.CreatedDate,
                treeDetail.CreatorUserID,
                treeDetail.Dap,
                treeDetail.Dap_Counter,
                treeDetail.EditedDate,
                treeDetail.EditorUserID,
                treeDetail.Height,
                treeDetail.Lat,
                treeDetail.Lon,
                treeDetail.X,
                treeDetail.Y,
                treeDetail.Number,
                treeDetail.ProjectOrganismID,
                treeDetail.Project_Organisms.ProjectID,
                treeDetail.Project_Organisms.OrganismID,
                treeDetail.Project_Organisms.Organism.CommonName.CommonNameDesc,
                treeDetail.Project_Organisms.Organism.CommonName.CommonNameID,
                treeDetail.Project_Organisms.Organism.ScientificName.ScientificNameDesc,
                treeDetail.Project_Organisms.Organism.ScientificName.ScientificNameID,
                treeDetail.TreeDetailsID,
                treeDetail.Varas
            };
            trees.Add(tree);
        }

        return(new JavaScriptSerializer().Serialize(trees));
    }
Exemplo n.º 8
0
        protected void rblActionProposed_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;
            int         actionProposedID  = Convert.ToInt32(rb.ID.Substring(rb.ID.LastIndexOf("_") + 1, rb.ID.Length - rb.ID.LastIndexOf("_") - 1)) + 1;
            int         projectOrganismID = Convert.ToInt32(rb.GroupName.Substring(rb.GroupName.LastIndexOf("_") + 1, rb.GroupName.Length - rb.GroupName.LastIndexOf("_") - 1));

            using (DatabaseContext _DatabaseContext = new DatabaseContext())
            {
                TreeDetail     treeDetail     = _DatabaseContext.TreeDetails.First(instance => instance.ProjectOrganismID == projectOrganismID);
                ActionProposed actionProposed = _DatabaseContext.ActionProposeds.First(instance => instance.ActionProposedID == actionProposedID);
                treeDetail.ActionProposedID = actionProposed.ActionProposedID;
                treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey;

                _DatabaseContext.SaveChanges();
            }
        }
Exemplo n.º 9
0
    public static void EditTreePosition(string projectOrganismID, string x, string y, string lat, string lon, string userID)
    {
        using (DatabaseContext _DatabaseContext = new DatabaseContext())
        {
            int        projectOrganismIDINT = Convert.ToInt32(projectOrganismID);
            TreeDetail treeDetail           = _DatabaseContext.TreeDetails.First(instance => instance.ProjectOrganismID == projectOrganismIDINT);
            treeDetail.X            = Convert.ToDecimal(x);
            treeDetail.Y            = Convert.ToDecimal(y);
            treeDetail.Lat          = Convert.ToDecimal(lat);
            treeDetail.Lon          = Convert.ToDecimal(lon);
            treeDetail.EditedDate   = DateTime.Now;
            treeDetail.EditorUserID = new Guid(userID);

            _DatabaseContext.SaveChanges();
        }
    }
Exemplo n.º 10
0
    public static void EditTreeActionProposedID(string actionProposedID, string projectOrganismID, string userID)
    {
        int actionProposedIDINT  = Convert.ToInt32(actionProposedID);
        int projectOrganismIDINT = Convert.ToInt32(projectOrganismID);

        using (DatabaseContext _DatabaseContext = new DatabaseContext())
        {
            TreeDetail     treeDetail     = _DatabaseContext.TreeDetails.First(instance => instance.ProjectOrganismID == projectOrganismIDINT);
            ActionProposed actionProposed = _DatabaseContext.ActionProposeds.First(instance => instance.ActionProposedID == actionProposedIDINT);
            treeDetail.ActionProposedID = actionProposed.ActionProposedID;
            treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey;
            treeDetail.EditedDate   = DateTime.Now;
            treeDetail.EditorUserID = new Guid(userID);

            _DatabaseContext.SaveChanges();
        }
    }
Exemplo n.º 11
0
        protected void ddlActionProposedChange_SelectedIndexChanged(object sender, EventArgs e)
        {
            int actionProposedChangeID = Convert.ToInt32(ddlActionProposedChange.SelectedValue);

            using (DatabaseContext _DatabaseContext = new DatabaseContext())
            {
                foreach (GridViewRow row in gridViewTreeDetails.Rows)
                {
                    // Save the ProjectID value for deletion
                    // First, get the ProjectID for the selected row
                    Int32          treeDetailsID  = (Int32)gridViewTreeDetails.DataKeys[row.RowIndex].Value;
                    TreeDetail     treeDetail     = _DatabaseContext.TreeDetails.First(instance => instance.TreeDetailsID == treeDetailsID);
                    ActionProposed actionProposed = _DatabaseContext.ActionProposeds.First(instance => instance.ActionProposedID == actionProposedChangeID);
                    treeDetail.ActionProposedID = actionProposed.ActionProposedID;
                    treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey;

                    _DatabaseContext.SaveChanges();
                }
            }
            ddlActionProposedChange.SelectedIndex = 0;
        }
Exemplo n.º 12
0
    protected void FormViewTlProject_Organism_DataBinding(object sender, EventArgs e)
    {
        string project_organismID = Page.RouteData.Values["project_organism_id"] as string;

        if (project_organismID != null && project_organismID != "0")
        {
            this.tree    = new Project_OrganismsBLL().GetProject_OrganismsByProjectOrganismID(Convert.ToInt32(project_organismID));
            this.editor  = new Eisk.BusinessLogicLayer.UserBLL().GetUserByUserID(tree.EditorUserID);
            this.creator = new Eisk.BusinessLogicLayer.UserBLL().GetUserByUserID(tree.CreatorUserID);

            if (tree.TreeDetails.Count > 0)
            {
                this.treeDetail = tree.TreeDetails.First();
            }

            if (tree.Organism != null)
            {
                this.organism = tree.Organism;
            }
        }
    }
Exemplo n.º 13
0
        public void DeleteProject_OrganismByProjectOrganismID(Project_Organisms project_Organism)
        {
            int        treeDetailsIDINT = project_Organism.TreeDetails.ToArray()[0].TreeDetailsID;
            TreeDetail treeDetail       = _DatabaseContext.TreeDetails.First(instance => instance.TreeDetailsID == treeDetailsIDINT);

            List <Dap> tempDaps = _DatabaseContext.Daps.Where(instance => instance.TreeDetailsID == treeDetailsIDINT).ToList();

            foreach (Dap dap in tempDaps)
            {
                _DatabaseContext.Daps.DeleteObject(dap);
            }

            _DatabaseContext.TreeDetails.DeleteObject(treeDetail);
            _DatabaseContext.Project_Organisms.DeleteObject(project_Organism);

            _DatabaseContext.SaveChanges();

            //Sort Numbers after deleting
            int projectIDINT = Convert.ToInt32(project_Organism.ProjectID);
            List <TreeDetail> treeDetails =
                _DatabaseContext.TreeDetails
                .Where(instance => instance.Project_Organisms.ProjectID == projectIDINT)
                .OrderBy(instance => instance.Number)
                .ToList();

            int number = 1;

            foreach (TreeDetail tDetail in treeDetails)
            {
                tDetail.Number = number;
                number++;
            }
            //

            _DatabaseContext.SaveChanges();
        }
Exemplo n.º 14
0
    protected void OdsProject_Organism_Details_Inserted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e)
    {
        int result = Convert.ToInt32(e.ReturnValue, System.Globalization.CultureInfo.CurrentCulture.NumberFormat);

        //string lat = "";
        //string lon = "";
        if (result != 0)
        {
            Project_Organisms       project_Organisms       = new Project_OrganismsBLL().GetProject_OrganismsByProjectOrganismID(result);
            ProjectInfoTreeLocation projectInfoTreeLocation = new ProjectInfoTreeLocationBLL().GetProjectInfoTreeLocationsByProjectID(project_Organisms.ProjectID)[0];
            bool fromInventory = false;

            UserBLL userBLL = new UserBLL();
            Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name);

            if (user != null)
            {
                // TreeDetail
                TextBox     txtVaras      = (TextBox)formViewTlProject_Organism.FindControl("txtVaras");
                HiddenField hfDap         = (HiddenField)formViewTlProject_Organism.FindControl("hfDap");
                TextBox     txtDap        = (TextBox)formViewTlProject_Organism.FindControl("txtDap");
                TextBox     txtDapCounter = (TextBox)formViewTlProject_Organism.FindControl("txtDapCounter");
                TextBox     txtHeight     = (TextBox)formViewTlProject_Organism.FindControl("txtHeight");
                TextBox     txtCommentary = (TextBox)formViewTlProject_Organism.FindControl("txtCommentary");

                Label   lblNumber = (Label)formViewTlProject_Organism.FindControl("lblNumber");
                TextBox txtX      = (TextBox)formViewTlProject_Organism.FindControl("txtX");
                TextBox txtY      = (TextBox)formViewTlProject_Organism.FindControl("txtY");
                TextBox txtLat    = (TextBox)formViewTlProject_Organism.FindControl("txtLat");
                TextBox txtLon    = (TextBox)formViewTlProject_Organism.FindControl("txtLon");

                RadioButtonList rblActionProposed = (RadioButtonList)formViewTlProject_Organism.FindControl("rblActionProposed");
                RadioButtonList rblCondition      = (RadioButtonList)formViewTlProject_Organism.FindControl("rblCondition");

                // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                // Edgardo Ramos - 20130928
                CheckBox chkLittoral     = (CheckBox)formViewTlProject_Organism.FindControl("chkLittoral");
                CheckBox chkMaritimeZone = (CheckBox)formViewTlProject_Organism.FindControl("chkMaritimeZone");
                // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                TreeDetail treeDetail = new TreeDetail();

                if (!string.IsNullOrEmpty(txtVaras.Text) && txtVaras.Text != "0") // Is Cepa
                {
                    treeDetail.Dap         = 0;
                    treeDetail.Dap_Counter = 0;
                }
                else if (txtDapCounter.Text == "1") // Solo un Dap
                {
                    //treeDetail.Dap = Convert.ToDecimal(txtDap.Text);// new DapBLL().GetDap(0);
                    //treeDetail.Dap_Counter = Convert.ToInt32(txtDapCounter.Text); //new DapBLL().GetDapCount(0);
                    treeDetail.Dap         = Convert.ToDecimal(hfDap.Value); // new DapBLL().GetDap(0);
                    treeDetail.Dap_Counter = Convert.ToInt32(1);             //new DapBLL().GetDapCount(0);
                }
                else // Mas de un Dap
                {
                    string[] daps     = hfDap.Value.Split(',');
                    double   dapTotal = 0;
                    foreach (string dap in daps)
                    {
                        dapTotal += Convert.ToDouble(dap);
                    }//dapTotal;// new DapBLL().GetDap(0);
                    treeDetail.Dap         = Convert.ToDecimal(Math.Round(Math.Sqrt(Math.Pow(dapTotal, 2D) / Convert.ToDouble(daps.Count())) * 100) / 100);
                    treeDetail.Dap_Counter = Convert.ToInt32(txtDapCounter.Text); //new DapBLL().GetDapCount(0);
                }

                treeDetail.Varas = Convert.ToInt32(string.IsNullOrEmpty(txtVaras.Text) ? "0" : txtVaras.Text);

                treeDetail.Height     = Convert.ToDecimal(txtHeight.Text);
                treeDetail.Commentary = (txtCommentary.Text.Length > txtCommentary.MaxLength) ? txtCommentary.Text.Substring(0, txtCommentary.MaxLength) : txtCommentary.Text;

                treeDetail.Number = Convert.ToInt32(lblNumber.Text);


                // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                // Edgardo Ramos - 20130928
                decimal         dec;
                RadioButtonList rblPosition = (RadioButtonList)formViewTlProject_Organism.FindControl("rblPosition");

                if (rblPosition.SelectedValue == "0") // Nad83
                {
                    treeDetail.X = decimal.TryParse(txtX.Text, out dec) ? Convert.ToDecimal(txtX.Text) : 0;
                    treeDetail.Y = decimal.TryParse(txtY.Text, out dec) ? Convert.ToDecimal(txtY.Text) : 0;

                    if (treeDetail.X != 0 && treeDetail.Y != 0)
                    {
                        Dictionary <string, object> anewpointObj = Utility.ConvertToLatLng(treeDetail.X.ToString(), treeDetail.Y.ToString(), @"~/App_Resources/client-scripts/tl/");

                        treeDetail.Lat = Convert.ToDecimal(anewpointObj["y"]);
                        txtLat.Text    = treeDetail.Lat.ToString();
                        treeDetail.Lon = Convert.ToDecimal(anewpointObj["x"]);
                        txtLon.Text    = treeDetail.Lon.ToString();
                    }
                    else
                    {
                        treeDetail.Lat = 0;
                        treeDetail.Lon = 0;
                    }
                }
                else // StatePlanes
                {
                    treeDetail.Lat = decimal.TryParse(txtLat.Text, out dec) ? Convert.ToDecimal(txtLat.Text) : 0;
                    treeDetail.Lon = decimal.TryParse(txtLon.Text, out dec) ? Convert.ToDecimal(txtLon.Text) : 0;

                    if (treeDetail.Lat != 0 && treeDetail.Lon != 0)
                    {
                        Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(treeDetail.Lon.ToString(), treeDetail.Lat.ToString(), @"~/App_Resources/client-scripts/tl/");

                        treeDetail.X = Convert.ToDecimal(anewpointObj["x"]);
                        txtX.Text    = treeDetail.X.ToString();
                        treeDetail.Y = Convert.ToDecimal(anewpointObj["y"]);
                        txtY.Text    = treeDetail.Y.ToString();
                    }
                    else
                    {
                        treeDetail.X = 0;
                        treeDetail.Y = 0;
                    }
                }

                //treeDetail.X = Convert.ToDecimal(txtX.Text);
                //treeDetail.Y = Convert.ToDecimal(txtY.Text);
                //treeDetail.Lat = Convert.ToDecimal(txtLat.Text);
                //treeDetail.Lon = Convert.ToDecimal(txtLon.Text);

                treeDetail.Littoral     = chkLittoral.Checked;
                treeDetail.MaritimeZone = chkMaritimeZone.Checked;

                // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                treeDetail.CreatedDate   = DateTime.Now;
                treeDetail.CreatorUserID = user.UserID;
                treeDetail.EditedDate    = DateTime.Now;
                treeDetail.EditorUserID  = user.UserID;

                ActionProposed actionProposed = new ActionProposedBLL().GetActionProposedByActionProposedID(Convert.ToInt32(rblActionProposed.SelectedValue));
                treeDetail.ActionProposedID = actionProposed.ActionProposedID;
                treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey;

                Condition condition = new ConditionBLL().GetConditionByConditionID(Convert.ToInt32(rblCondition.SelectedValue));
                treeDetail.ConditionID = condition.ConditionID;
                treeDetail.ConditionReference.EntityKey = condition.EntityKey;

                treeDetail.ProjectOrganismID = project_Organisms.ProjectOrganismID;
                treeDetail.Project_OrganismsReference.EntityKey = project_Organisms.EntityKey;

                int treeDetailID = new TreeDetailBLL().CreateNewTreeDetail(treeDetail);

                if (treeDetail.Varas != null && treeDetail.Varas > 0) // Is Cepa
                {
                    //
                }
                else if (txtDapCounter.Text == "1") // Solo un Dap
                {
                    Dap dap = new Dap();
                    dap.DapValue      = Convert.ToDecimal(hfDap.Value);
                    dap.TreeDetailsID = treeDetailID;
                    dap.TreeDetailReference.EntityKey = treeDetail.EntityKey;

                    new DapBLL().CreateNewDap(dap);
                }
                else // Mas de un Dap
                {
                    string[] daps = hfDap.Value.Split(',');
                    foreach (string dapString in daps)
                    {
                        Dap dap = new Dap();
                        dap.DapValue      = Convert.ToDecimal(dapString);
                        dap.TreeDetailsID = treeDetailID;
                        dap.TreeDetailReference.EntityKey = treeDetail.EntityKey;

                        new DapBLL().CreateNewDap(dap);
                    }
                }

                fromInventory = Convert.ToDecimal(projectInfoTreeLocation.X) == Convert.ToDecimal(treeDetail.X) && Convert.ToDecimal(projectInfoTreeLocation.Y) == Convert.ToDecimal(treeDetail.Y);
                //
            }

            if (fromInventory)
            {
                Response.RedirectToRoute("tl-treeinventory", new { project_id = RouteData.Values["project_id"] });
            }
            else
            {
                Response.RedirectToRoute("tl", new { Project_id = RouteData.Values["Project_id"] });
                Response.RedirectLocation += "?poid=" + project_Organisms.ProjectOrganismID + "&lat=0&lon=0";
            }

            //Response.RedirectToRoute("tl-tree-details_edit", new { edit_mode = "edit", project_id = Page.RouteData.Values["project_id"] as string, project_organism_id = result });
        }
    }
Exemplo n.º 15
0
    protected void FormViewTlProject_Organism_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        User editor = new UserBLL().GetUserByUserName((HttpContext.Current.User.Identity).Name);

        Project_Organisms project_Organisms = new Project_OrganismsBLL().GetProject_OrganismsByProjectOrganismID((int)e.Keys["ProjectOrganismID"]);

        using (DatabaseContext _DatabaseContext = new DatabaseContext())
        {
            // TreeDetail
            TextBox     txtVaras      = (TextBox)formViewTlProject_Organism.FindControl("txtVaras");
            HiddenField hfDap         = (HiddenField)formViewTlProject_Organism.FindControl("hfDap");
            TextBox     txtHeight     = (TextBox)formViewTlProject_Organism.FindControl("txtHeight");
            TextBox     txtCommentary = (TextBox)formViewTlProject_Organism.FindControl("txtCommentary");

            Label   lblNumber = (Label)formViewTlProject_Organism.FindControl("lblNumber");
            TextBox txtX      = (TextBox)formViewTlProject_Organism.FindControl("txtX");
            TextBox txtY      = (TextBox)formViewTlProject_Organism.FindControl("txtY");
            TextBox txtLat    = (TextBox)formViewTlProject_Organism.FindControl("txtLat");
            TextBox txtLon    = (TextBox)formViewTlProject_Organism.FindControl("txtLon");

            RadioButtonList rblActionProposed = (RadioButtonList)formViewTlProject_Organism.FindControl("rblActionProposed");
            RadioButtonList rblCondition      = (RadioButtonList)formViewTlProject_Organism.FindControl("rblCondition");

            // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            // Edgardo Ramos - 20130928
            CheckBox chkLittoral     = (CheckBox)formViewTlProject_Organism.FindControl("chkLittoral");
            CheckBox chkMaritimeZone = (CheckBox)formViewTlProject_Organism.FindControl("chkMaritimeZone");
            CheckBox cbCepa          = (CheckBox)formViewTlProject_Organism.FindControl("cbCepa");
            // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

            TreeDetail treeDetail = _DatabaseContext.TreeDetails.First(instance => instance.ProjectOrganismID == project_Organisms.ProjectOrganismID);

            //Delete existing Daps
            foreach (Dap item in _DatabaseContext.Daps.Where(instance => instance.TreeDetailsID == treeDetail.TreeDetailsID).ToList())
            {
                _DatabaseContext.Daps.DeleteObject(item);
            }

            if (cbCepa.Checked)// Is Cepa
            {
                treeDetail.Dap         = 0;
                treeDetail.Dap_Counter = 0;

                treeDetail.Varas = Convert.ToInt32(string.IsNullOrEmpty(txtVaras.Text) ? "0" : txtVaras.Text);
            }
            else
            {
                treeDetail.Varas = 0;

                var dapsList = hfDap.Value.Split(',').ToList();
                if (dapsList.Count == 1) // Solo un Dap
                {
                    decimal dap = Convert.ToDecimal(dapsList[0]);

                    treeDetail.Dap         = dap;
                    treeDetail.Dap_Counter = 1;

                    Dap dapObj = new Dap();
                    dapObj.DapValue      = dap;
                    dapObj.TreeDetailsID = treeDetail.TreeDetailsID;
                    dapObj.TreeDetailReference.EntityKey = treeDetail.EntityKey;

                    _DatabaseContext.Daps.AddObject(dapObj);
                }
                else // 1 o Mas de un Dap
                {
                    string[] daps     = hfDap.Value.Split(',');
                    double   dapTotal = 0;
                    foreach (string dap in daps)
                    {
                        dapTotal += Convert.ToDouble(dap);
                    }
                    treeDetail.Dap         = Convert.ToDecimal(Math.Round(Math.Sqrt(Math.Pow(dapTotal, 2D) / Convert.ToDouble(daps.Count())) * 100) / 100);
                    treeDetail.Dap_Counter = daps.Count();

                    foreach (string dapString in daps)
                    {
                        Dap dap = new Dap();
                        dap.DapValue      = Convert.ToDecimal(dapString);
                        dap.TreeDetailsID = treeDetail.TreeDetailsID;
                        dap.TreeDetailReference.EntityKey = treeDetail.EntityKey;

                        _DatabaseContext.Daps.AddObject(dap);
                    }
                }
            }

            treeDetail.Height     = Convert.ToDecimal(txtHeight.Text);
            treeDetail.Commentary = (txtCommentary.Text.Length > txtCommentary.MaxLength) ? txtCommentary.Text.Substring(0, txtCommentary.MaxLength) : txtCommentary.Text;

            treeDetail.Number = Convert.ToInt32(lblNumber.Text);

            // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            // Edgardo Ramos - 20130928
            decimal         dec;
            RadioButtonList rblPosition = (RadioButtonList)formViewTlProject_Organism.FindControl("rblPosition");

            if (rblPosition.SelectedValue == "0") // Nad83
            {
                treeDetail.X = decimal.TryParse(txtX.Text, out dec) ? Convert.ToDecimal(txtX.Text) : 0;
                treeDetail.Y = decimal.TryParse(txtY.Text, out dec) ? Convert.ToDecimal(txtY.Text) : 0;

                if (treeDetail.X != 0 && treeDetail.Y != 0)
                {
                    Dictionary <string, object> anewpointObj = Utility.ConvertToLatLng(treeDetail.X.ToString(), treeDetail.Y.ToString(), @"~/App_Resources/client-scripts/tl/");

                    treeDetail.Lat = Convert.ToDecimal(anewpointObj["y"]);
                    txtLat.Text    = treeDetail.Lat.ToString();
                    treeDetail.Lon = Convert.ToDecimal(anewpointObj["x"]);
                    txtLon.Text    = treeDetail.Lon.ToString();
                }
                else
                {
                    treeDetail.Lat = 0;
                    treeDetail.Lon = 0;
                }
            }
            else // StatePlanes
            {
                treeDetail.Lat = decimal.TryParse(txtLat.Text, out dec) ? Convert.ToDecimal(txtLat.Text) : 0;
                treeDetail.Lon = decimal.TryParse(txtLon.Text, out dec) ? Convert.ToDecimal(txtLon.Text) : 0;

                if (treeDetail.Lat != 0 && treeDetail.Lon != 0)
                {
                    Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(treeDetail.Lon.ToString(), treeDetail.Lat.ToString(), @"~/App_Resources/client-scripts/tl/");

                    treeDetail.X = Convert.ToDecimal(anewpointObj["x"]);
                    txtX.Text    = treeDetail.X.ToString();
                    treeDetail.Y = Convert.ToDecimal(anewpointObj["y"]);
                    txtY.Text    = treeDetail.Y.ToString();
                }
                else
                {
                    treeDetail.X = 0;
                    treeDetail.Y = 0;
                }
            }

            //treeDetail.X = Convert.ToDecimal(txtX.Text);
            //treeDetail.Y = Convert.ToDecimal(txtY.Text);
            //treeDetail.Lat = Convert.ToDecimal(txtLat.Text);
            //treeDetail.Lon = Convert.ToDecimal(txtLon.Text);

            treeDetail.Littoral     = chkLittoral.Checked;
            treeDetail.MaritimeZone = chkMaritimeZone.Checked;

            // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

            treeDetail.EditedDate   = DateTime.Now;
            treeDetail.EditorUserID = editor.UserID;

            ActionProposed actionProposed = new ActionProposedBLL().GetActionProposedByActionProposedID(Convert.ToInt32(rblActionProposed.SelectedValue));
            treeDetail.ActionProposedID = actionProposed.ActionProposedID;
            treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey;

            Condition condition = new ConditionBLL().GetConditionByConditionID(Convert.ToInt32(rblCondition.SelectedValue));
            treeDetail.ConditionID = condition.ConditionID;
            treeDetail.ConditionReference.EntityKey = condition.EntityKey;

            treeDetail.ProjectOrganismID = project_Organisms.ProjectOrganismID;
            treeDetail.Project_OrganismsReference.EntityKey = project_Organisms.EntityKey;

            _DatabaseContext.SaveChanges();
            //
        }

        Type myType = (typeof(Project_Organisms));

        PropertyInfo[] props = myType.GetProperties();

        string[] arrNewValues = new string[e.NewValues.Keys.Count];
        e.NewValues.Keys.CopyTo(arrNewValues, 0);

        foreach (var prop in props)
        {
            if (("System.String,System.Int,System.DateTime,System.Guid,System.Boolean").IndexOf((prop.PropertyType).FullName) >= 0) // Si la propiedad es de tipo Guid, String, Int, Boolean o DateTime
            {
                if (!arrNewValues.Contains(prop.Name))
                {
                    e.NewValues[prop.Name] = prop.GetValue(project_Organisms, null);
                }
            }
        }

        e.NewValues["ProjectID"]  = RouteData.Values["Project_id"].ToString();
        e.NewValues["OrganismID"] = ((HiddenField)formViewTlProject_Organism.FindControl("hfOrganism")).Value;

        e.NewValues["EditorUserId"] = editor.UserID.ToString();
        e.NewValues["EditedDate"]   = DateTime.Now;
    }
Exemplo n.º 16
0
 partial void OnTreeDetailSaving(TreeDetail treeDetail);
Exemplo n.º 17
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------

        public TreeDetail CreateProject_Organism(int varas, decimal height, decimal lat, decimal lon, int[] daps, ActionProposed actionProposed, Condition condition, string commentary, Organism organism, Project project, Eisk.BusinessEntities.User user)
        {
            Project_Organisms project_Organism = new Project_Organisms();

            project_Organism.CreatorUserID = user.UserID;
            project_Organism.CreatedDate   = DateTime.Now;
            project_Organism.EditorUserID  = user.UserID;
            project_Organism.EditedDate    = DateTime.Now;

            project_Organism.OrganismID = organism.OrganismID;
            project_Organism.OrganismReference.EntityKey = organism.EntityKey;

            project_Organism.ProjectID = project.ProjectID;
            project_Organism.ProjectReference.EntityKey = project.EntityKey;

            int project_OrganismID = new Project_OrganismsBLL().CreateNewProject_Organisms(project_Organism);

            TreeDetail treeDetail = new TreeDetail();

            if (varas != 0) // Is Cepa
            {
                treeDetail.Dap         = 0;
                treeDetail.Dap_Counter = 0;
            }
            else if (daps.Length == 1) // Solo un Dap
            {
                treeDetail.Dap         = daps[0];
                treeDetail.Dap_Counter = 1;
            }
            else // Mas de un Dap
            {
                double dapTotal = 0;
                foreach (int dap in daps)
                {
                    dapTotal += dap;
                }
                treeDetail.Dap         = Convert.ToDecimal(Math.Round(Math.Sqrt(Math.Pow(dapTotal, 2D) / Convert.ToDouble(daps.Length)) * 100) / 100);
                treeDetail.Dap_Counter = daps.Length;
            }

            treeDetail.Varas = varas;

            treeDetail.Height     = height;
            treeDetail.Commentary = commentary;

            List <Project_Organisms> project_Organisms = new Project_OrganismsBLL().GetProject_OrganismsByProjectID(project.ProjectID);

            Dictionary <string, object> anewpointObj = JavaScriptHelper.ConvertToStatePlane(lon.ToString(), lat.ToString());

            treeDetail.Number = project_Organisms.Count;
            treeDetail.Y      = Convert.ToDecimal(anewpointObj["y"]);
            treeDetail.X      = Convert.ToDecimal(anewpointObj["x"]);
            treeDetail.Lat    = Convert.ToDecimal(lat);
            treeDetail.Lon    = Convert.ToDecimal(lon);

            treeDetail.CreatedDate   = DateTime.Now;
            treeDetail.CreatorUserID = user.UserID;
            treeDetail.EditedDate    = DateTime.Now;
            treeDetail.EditorUserID  = user.UserID;


            treeDetail.ActionProposedID = actionProposed.ActionProposedID;
            treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey;

            treeDetail.ConditionID = condition.ConditionID;
            treeDetail.ConditionReference.EntityKey = condition.EntityKey;

            treeDetail.ProjectOrganismID = project_Organism.ProjectOrganismID;
            treeDetail.Project_OrganismsReference.EntityKey = project_Organism.EntityKey;

            int treeDetailID = new TreeDetailBLL().CreateNewTreeDetail(treeDetail);

            foreach (decimal dapDecimal in daps)
            {
                Dap dap = new Dap();
                dap.DapValue      = dapDecimal;
                dap.TreeDetailsID = treeDetailID;
                dap.TreeDetailReference.EntityKey = treeDetail.EntityKey;

                new DapBLL().CreateNewDap(dap);
            }
            return(treeDetail);
        }
Exemplo n.º 18
0
 partial void OnTreeDetailCreated(TreeDetail treeDetail);
Exemplo n.º 19
0
 partial void OnTreeDetailCreating(TreeDetail treeDetail);
Exemplo n.º 20
0
 partial void OnTreeDetailUpdated(TreeDetail treeDetail);
Exemplo n.º 21
0
 partial void OnTreeDetailUpdating(TreeDetail treeDetail);
Exemplo n.º 22
0
        protected void ButtonDeleteSelected_Click(object sender, System.EventArgs e)
        {
            try
            {
                // Create a List to hold the ProjectID values to delete
                List <Int32> TreeDetailIDsToDelete       = new List <Int32>();
                List <Int32> ProjectOrganismsIDsToDelete = new List <Int32>();
                List <Int32> DapIDsToDelete = new List <Int32>();

                // Iterate through the Projects.Rows property
                foreach (GridViewRow row in gridViewTreeDetails.Rows)
                {
                    // Access the CheckBox
                    CheckBox cb = (CheckBox)(row.FindControl("chkTreeDetailsSelector"));
                    if (cb != null && cb.Checked)
                    {
                        // Save the ProjectID value for deletion
                        // First, get the ProjectID for the selected row
                        Int32 treeDetailsID = (Int32)gridViewTreeDetails.DataKeys[row.RowIndex].Value;
                        Eisk.BusinessEntities.TreeDetail treeDetail = new TreeDetailBLL().GetTreeDetailByTreeDetailsID(treeDetailsID);

                        List <Int32> tempDaps = new DapBLL().GetDapsByTreeDetailsID(treeDetailsID).Select(instance => instance.DapID).ToList();

                        // Add it to the List...
                        ProjectOrganismsIDsToDelete.Add(treeDetail.ProjectOrganismID);
                        TreeDetailIDsToDelete.Add(treeDetail.TreeDetailsID);
                        DapIDsToDelete.AddRange(tempDaps);
                    }
                }

                using (DatabaseContext _DatabaseContext = new DatabaseContext())
                {
                    foreach (int dapID in DapIDsToDelete)
                    {
                        Dap dap = _DatabaseContext.Daps.First(instance => instance.DapID == dapID);
                        _DatabaseContext.Daps.DeleteObject(dap);

                        _DatabaseContext.SaveChanges();
                    }
                    foreach (int treeDetailsID in TreeDetailIDsToDelete)
                    {
                        TreeDetail treeDetail = _DatabaseContext.TreeDetails.First(instance => instance.TreeDetailsID == treeDetailsID);
                        _DatabaseContext.TreeDetails.DeleteObject(treeDetail);

                        _DatabaseContext.SaveChanges();
                    }
                    foreach (int ProjectOrganismID in ProjectOrganismsIDsToDelete)
                    {
                        Project_Organisms project_Organism = _DatabaseContext.Project_Organisms.First(instance => instance.ProjectOrganismID == ProjectOrganismID);
                        _DatabaseContext.Project_Organisms.DeleteObject(project_Organism);

                        _DatabaseContext.SaveChanges();
                    }

                    //Sort Numbers after deleting
                    int projectIDINT = Convert.ToInt32(RouteData.Values["Project_id"]);
                    List <TreeDetail> treeDetails =
                        _DatabaseContext.TreeDetails
                        .Where(instance => instance.Project_Organisms.ProjectID == projectIDINT)
                        .OrderBy(instance => instance.Number)
                        .ToList();

                    int number = 1;
                    foreach (TreeDetail tDetail in treeDetails)
                    {
                        tDetail.Number = number;
                        number++;
                    }
                    //

                    _DatabaseContext.SaveChanges();
                }

                // Add a confirmation message
                ltlMessage.Text += String.Format(MessageFormatter.GetFormattedSuccessMessage("Eliminación de árboles satisfactoria. <b>{0}</b> árboles eliminados"), ProjectOrganismsIDsToDelete.Count);
            }
            catch (Exception ex)
            {
                ltlMessage.Text = ExceptionManager.DoLogAndGetFriendlyMessageForException(ex);
            }

            //binding the grid
            gridViewTreeDetails.PageIndex = 0;
            gridViewTreeDetails.PageSize  = Convert.ToInt32(ddlPageSize.SelectedValue);
            gridViewTreeDetails.DataBind();
        }
Exemplo n.º 23
0
 partial void OnTreeDetailSaved(TreeDetail treeDetail);
Exemplo n.º 24
0
        public static object GetProjectOrganismObject(Project_Organisms organism)
        {
            TreeDetail treeDetail = organism.TreeDetails.First();

            return(GetProjectOrganismObject(treeDetail));
        }
Exemplo n.º 25
0
 partial void OnTreeDetailDeleting(TreeDetail treeDetail);
Exemplo n.º 26
0
 partial void OnTreeDetailDeleted(TreeDetail treeDetail);
Exemplo n.º 27
0
 /// <summary>
 /// Deprecated Method for adding a new object to the TreeDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTreeDetails(TreeDetail treeDetail)
 {
     base.AddObject("TreeDetails", treeDetail);
 }
Exemplo n.º 28
0
        public object Update([FromBody] ProjectOrganismUpdateModel projectOrganismUpdate)
        {
            //var projectOrganism = (Project_Organisms)HttpContext.Current.Items["projectOrganism"];
            //var organism = (Organism)HttpContext.Current.Items["organism"];
            var project = (Project)HttpContext.Current.Items["project"];
            var groups  = (List <Group>)HttpContext.Current.Items["groups"];
            var user    = (User)HttpContext.Current.Items["user"];
            //var actionProposed = (ActionProposed)HttpContext.Current.Items["actionProposed"];
            //var condition = (Condition)HttpContext.Current.Items["condition"];
            var daps  = (int[])HttpContext.Current.Items["daps"];
            var varas = (int)HttpContext.Current.Items["varas"];


            using (DatabaseContext _DatabaseContext = new DatabaseContext())
            {
                // TreeDetail
                Project_Organisms projectOrganism = _DatabaseContext.Project_Organisms.First(instance => instance.ProjectOrganismID == projectOrganismUpdate.ProjectOrganismID);
                TreeDetail        treeDetail      = _DatabaseContext.TreeDetails.First(instance => instance.ProjectOrganismID == projectOrganism.ProjectOrganismID);

                //Delete existing Daps
                foreach (Dap item in _DatabaseContext.Daps.Where(instance => instance.TreeDetailsID == treeDetail.TreeDetailsID).ToList())
                {
                    _DatabaseContext.Daps.DeleteObject(item);
                }

                if (varas != 0) // Is Cepa
                {
                    treeDetail.Dap         = 0;
                    treeDetail.Dap_Counter = 0;
                }
                else if (daps.Length == 1) // Solo un Dap
                {
                    treeDetail.Dap         = Convert.ToDecimal(daps[0]);
                    treeDetail.Dap_Counter = 1;

                    Dap dapObj = new Dap();
                    dapObj.DapValue      = Convert.ToDecimal(daps[0]);
                    dapObj.TreeDetailsID = treeDetail.TreeDetailsID;
                    dapObj.TreeDetailReference.EntityKey = treeDetail.EntityKey;

                    _DatabaseContext.Daps.AddObject(dapObj);
                }
                else // 1 o Mas de un Dap
                {
                    double dapTotal = 0;
                    foreach (int dap in daps)
                    {
                        dapTotal += Convert.ToDouble(dap);
                    }
                    //dapTotal;// new DapBLL().GetDap(0);
                    treeDetail.Dap         = Convert.ToDecimal(Math.Round(Math.Sqrt(Math.Pow(dapTotal, 2D) / Convert.ToDouble(daps.Count())) * 100) / 100);
                    treeDetail.Dap_Counter = Convert.ToInt32(daps.Length); //new DapBLL().GetDapCount(0);

                    foreach (int dapInt in daps)
                    {
                        Dap dap = new Dap();
                        dap.DapValue      = Convert.ToDecimal(dapInt);
                        dap.TreeDetailsID = treeDetail.TreeDetailsID;
                        dap.TreeDetailReference.EntityKey = treeDetail.EntityKey;

                        _DatabaseContext.Daps.AddObject(dap);
                    }
                }

                //treeDetail.Dap = new DapBLL().GetDap(treeDetail.TreeDetailsID); //Convert.ToDecimal(hfDap.Value);
                //treeDetail.Dap_Counter = new DapBLL().GetDapCount(treeDetail.TreeDetailsID); //Convert.ToInt32(hfDapCounter.Value);

                treeDetail.Varas = projectOrganismUpdate.Varas;

                treeDetail.Height = Convert.ToDecimal(projectOrganismUpdate.Height);
                int CommentaryMaxLength = Convert.ToInt32(ConfigurationManager.AppSettings["CommentaryMaxLength"]);
                if (!string.IsNullOrEmpty(projectOrganismUpdate.Commentary))
                {
                    treeDetail.Commentary = (projectOrganismUpdate.Commentary.Length > CommentaryMaxLength) ? projectOrganismUpdate.Commentary.Substring(0, CommentaryMaxLength) : projectOrganismUpdate.Commentary;
                }
                else
                {
                    treeDetail.Commentary = "";
                }

                treeDetail.Number = Convert.ToInt32(treeDetail.Number);

                treeDetail.Lat = Convert.ToDecimal(projectOrganismUpdate.Lat);
                treeDetail.Lon = Convert.ToDecimal(projectOrganismUpdate.Lon);
                Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(projectOrganismUpdate.Lon.ToString(), projectOrganismUpdate.Lat.ToString(), @"~/Javascript/");
                treeDetail.X = Convert.ToDecimal(anewpointObj["x"]);
                treeDetail.Y = Convert.ToDecimal(anewpointObj["y"]);
                //

                treeDetail.EditedDate   = DateTime.Now;
                treeDetail.EditorUserID = user.UserID;

                //projectOrganism
                Organism organism = new OrganismBLL().GetOrganismByOrganismID(Convert.ToInt32(projectOrganismUpdate.OrganismID));
                projectOrganism.OrganismID = organism.OrganismID;
                projectOrganism.OrganismReference.EntityKey = organism.EntityKey;

                //ActionProposed
                ActionProposed actionProposed = new ActionProposedBLL().GetActionProposedByActionProposedID(Convert.ToInt32(projectOrganismUpdate.ActionProposedID));
                treeDetail.ActionProposedID = actionProposed.ActionProposedID;
                treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey;

                //Condition
                Condition condition = new ConditionBLL().GetConditionByConditionID(Convert.ToInt32(projectOrganismUpdate.ConditionID));
                treeDetail.ConditionID = condition.ConditionID;
                treeDetail.ConditionReference.EntityKey = condition.EntityKey;

                treeDetail.ProjectOrganismID = (int)projectOrganismUpdate.ProjectOrganismID;
                treeDetail.Project_OrganismsReference.EntityKey = projectOrganism.EntityKey;

                _DatabaseContext.SaveChanges();
                //
            }

            var updatedProjectOrganism = new Project_OrganismsBLL().GetProject_OrganismsByProjectOrganismID((int)projectOrganismUpdate.ProjectOrganismID);

            return(ProjectOrganismModel.GetProjectOrganismObject(updatedProjectOrganism));
        }