Ejemplo n.º 1
0
        /// <summary>
        /// Populate Sector by Id
        /// </summary>
        /// <param name="search"></param>
        public TSMSector GetSectorByID(Guid id)
        {
            TSMSector objSector = new TSMSector();

            try
            {
                objSector = SectorService.GetSector(id);

                if (objSector != null)
                {
                    this.ParentNomenclature = new List <TSMSector>();
                    this.ChildNomenclature  = new List <TSMSector>();

                    this.ID = objSector.ID;
                    this.Nomenclaturetype = objSector.NomenclatureType;
                    this.Sectortype       = objSector.Type;
                    this.ParentCode       = objSector.ParentID.ToString();
                    this.SectorName       = objSector.Name;
                    this.NomenclatureCode = objSector.Code;
                    this.IsActive         = objSector.IsActive;
                }
            }
            catch (Exception ex)
            {
                ErrorLog.WriteLog("ManageUserModel", "Populate", ex, "");
            }
            return(objSector);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save
        /// </summary>
        public TSMSector Save()
        {
            TSMSector tsmSector = new TSMSector();

            try
            {
                if (this.ID != Guid.Empty)
                {
                    tsmSector                  = SectorService.GetSector(this.ID);
                    tsmSector.ID               = this.ID;
                    tsmSector.LastModifiedBy   = TSM.Model.TSMContext.CurrentUser.ID;
                    tsmSector.LastModifiedDate = DateTime.UtcNow;
                }
                else
                {
                    tsmSector             = new TSMSector();
                    tsmSector.CreatedBy   = TSM.Model.TSMContext.CurrentUser.ID;
                    tsmSector.CreatedDate = DateTime.UtcNow;
                }

                tsmSector.LanguageID       = TSMContext.CurrentLanguageID;
                tsmSector.Code             = this.NomenclatureCode;
                tsmSector.IsActive         = this.IsActive;
                tsmSector.IsDeleted        = false;
                tsmSector.Name             = this.SectorName;
                tsmSector.NomenclatureType = this.Nomenclaturetype;
                Guid newGuid = new Guid();
                try
                {
                    var childcode  = this.ChildCode;
                    var parentCode = this.ParentCode;
                    if (childcode != null)
                    {
                        newGuid            = Guid.Parse(childcode);
                        tsmSector.ParentID = newGuid;
                    }
                    else if (parentCode != null)
                    {
                        newGuid            = Guid.Parse(parentCode);
                        tsmSector.ParentID = newGuid;
                    }
                }
                catch { tsmSector.ParentID = null; }
                tsmSector.Type = this.Sectortype;

                SectorService.Save(tsmSector);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteLog("ManageUserModel", "Save", ex, "");
            }
            return(tsmSector);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Delete Sector
        /// </summary>
        /// <param name="id"></param>
        /// <param name="Model"></param>
        public void Delete(Guid id)
        {
            TSMSector tsmSector = SectorService.GetSector(id);

            if (tsmSector != null)
            {
                tsmSector.IsActive         = false;
                tsmSector.IsDeleted        = true;
                tsmSector.LastModifiedBy   = TSMContext.CurrentUser.ID;
                tsmSector.LastModifiedDate = DateTime.UtcNow;
                SectorService.Delete(tsmSector);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Populate Sector
        /// </summary>
        /// <param name="search"></param>
        public TSMSector GetSector(Guid id)
        {
            TSMSector objSector = new TSMSector();

            try
            {
                objSector = SectorService.GetSector(id);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteLog("ManageUserModel", "Populate", ex, "");
            }
            return(objSector);
        }