public ActionResult Edit(int id) { objTenancyService = new TenancyService(); objTenancyItem = new TenancyItem(); // string strid = objTenancyService.Decrypt(id.ToString()); //string strid = id.ToString(); //int Tid = Convert.ToInt32(strid); objTenancyItem = objTenancyService.GetByid(id); //CompanyBind List <CompanyItem> lstCompany = new List <CompanyItem>(); lstCompany = objTenancyService.GetCompany(); objTenancyItem.ListCompany = new List <CompanyItem>(); objTenancyItem.ListCompany.AddRange(lstCompany); //Employee Bind List <EmployeeItem> lstEmp = new List <EmployeeItem>(); lstEmp = objTenancyService.GetEmployee(); objTenancyItem.ListEmployee = new List <EmployeeItem>(); objTenancyItem.ListEmployee.AddRange(lstEmp); // ListGrid bind List <TenancyItem> ListTenancy = new List <TenancyItem>(); ListTenancy = objTenancyService.getTenancyDoc(id); objTenancyItem.ListTenancy = new List <TenancyItem>(); objTenancyItem.ListTenancy.AddRange(ListTenancy); //TenancyType List <clsMasterData> lstTT = new List <clsMasterData>(); lstTT = objTenancyService.GetTenancyType(); objTenancyItem.ListTT = new List <clsMasterData>(); objTenancyItem.ListTT.AddRange(lstTT); //ViewBag.Menuid = objTenancyService.Decrypt(Request.QueryString["menuid"]); ViewBag.Menuid = (Request.QueryString["menuid"]); return(View(objTenancyItem)); }
public ActionResult Create() { objTenancyService = new TenancyService(); objTenancyItem = new TenancyItem(); //CompanyBind List <CompanyItem> lstCompany = new List <CompanyItem>(); lstCompany = objTenancyService.GetCompany(); objTenancyItem.ListCompany = new List <CompanyItem>(); objTenancyItem.ListCompany.AddRange(lstCompany); //Employee Bind List <EmployeeItem> lstEmp = new List <EmployeeItem>(); lstEmp = objTenancyService.GetEmployee(); objTenancyItem.ListEmployee = new List <EmployeeItem>(); objTenancyItem.ListEmployee.AddRange(lstEmp); // ListGrid bind int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } List <TenancyItem> ListTenancy = new List <TenancyItem>(); ListTenancy = objTenancyService.GetAll(cid); objTenancyItem.ListTenancy = new List <TenancyItem>(); // objTenancyItem.ListTenancy.Add(new TenancyItem{TnID=Encrypt(ListTenancy)}) objTenancyItem.ListTenancy.AddRange(ListTenancy); //TenancyType List <clsMasterData> lstTT = new List <clsMasterData>(); lstTT = objTenancyService.GetTenancyType(); objTenancyItem.ListTT = new List <clsMasterData>(); objTenancyItem.ListTT.AddRange(lstTT); ViewBag.Menuid = (Request.QueryString["menuid"]); return(View(objTenancyItem)); }
/// <summary> /// Adds the Tenancy client to a service collection. /// </summary> /// <param name="services">The service collection.</param> /// <param name="enableResponseCaching">Flag indicating whether or not response caching should be enabled for GET operations.</param> /// <returns>The modified service collection.</returns> /// <remarks> /// <para> /// This requires the <see cref="TenancyClientOptions"/> to be available from DI in order /// to discover the base URI of the Operations control service, and, if required, to /// specify the resource id to use when obtaining an authentication token representing the /// hosting service's identity. /// </para> /// <para> /// This also requires an implementation of <see cref="IServiceIdentityAccessTokenSource"/> /// to be available via DI. This is normally achieved through one of the various /// <c>AddServiceIdentityAzureTokenCredentialSource...</c> extension methods available when /// you install the <c>Corvus.Identity.Azure</c> NuGet package, but applications are free /// to supply alternate implementations. /// </para> /// </remarks> public static IServiceCollection AddTenancyClient( this IServiceCollection services, bool enableResponseCaching) { if (services.Any(s => s.ServiceType == typeof(ITenancyService))) { return(services); } services.AddContentTypeBasedSerializationSupport(); services.AddSingleton((Func <IServiceProvider, ITenancyService>)(sp => { TenancyClientOptions options = sp.GetRequiredService <TenancyClientOptions>(); DelegatingHandler[] handlers = enableResponseCaching ? new DelegatingHandler[] { new CachingHandler() } : Array.Empty <DelegatingHandler>(); TenancyService service; if (string.IsNullOrWhiteSpace(options.ResourceIdForMsiAuthentication)) { service = new UnauthenticatedTenancyService(options.TenancyServiceBaseUri, handlers); } else { var tokenCredentials = new TokenCredentials( sp.GetRequiredService <IServiceIdentityMicrosoftRestTokenProviderSource>().GetTokenProvider( $"{options.ResourceIdForMsiAuthentication}/.default")); service = new TenancyService(options.TenancyServiceBaseUri, tokenCredentials, handlers); } JsonSerializerSettings serializerSettings = sp.GetRequiredService <IJsonSerializerSettingsProvider>().Instance; serializerSettings.Converters.ForEach(service.SerializationSettings.Converters.Add); serializerSettings.Converters.ForEach(service.DeserializationSettings.Converters.Add); service.DeserializationSettings.DateParseHandling = serializerSettings.DateParseHandling; return(service); })); return(services); }
public ActionResult deleteDoc(int id, int DID, int menuid) { //int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString()); TenancyService objTenService = new TenancyService(); TenancyDocumentItem objDoc = new TenancyDocumentItem(); objDoc = objTenService.getByID(DID); string path = objDoc.FileUrl; var fullPath = Server.MapPath(path); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } db.TenancyDocuments.Remove(db.TenancyDocuments.Find(DID)); db.SaveChanges(); //ViewBag.Empid = Empid; ViewBag.Menuid = Request.QueryString["menuId"]; return(RedirectToAction("Edit", new { @id = id, @menuId = Request.QueryString["menuId"] })); }
public ActionResult delete(int id, int menuid) { try { //int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString()); TenancyService objTenService = new TenancyService(); TenancyItem objDoc = new TenancyItem(); objDoc = objTenService.GetByid(id); db.TenancyMasters.Remove(db.TenancyMasters.Find(id)); db.SaveChanges(); //ViewBag.Empid = Empid; ViewBag.Menuid = Request.QueryString["menuId"]; } catch (Exception ex) { ViewBag.ErrorMsg = "First Delete This Tenancy No's All Documents. "; //ViewBag.Action = "Create"; //ViewBag.Controller = "TenancyController"; //ViewBag.view = "Tenancy" + id + menuid; return(View("Error")); } return(RedirectToAction("Create", new { @id = id, @menuId = Request.QueryString["menuId"] })); }
public ActionResult Edit(TenancyItem model, HttpPostedFileBase[] files) { objTenancyService = new TenancyService(); objTenancyItem = new TenancyItem(); string uid = null; if (Session["UserId"] != null) { uid = Session["UserId"].ToString(); } model.UpdatedBy = uid; model.UpdatedDate = System.DateTime.Now; objTenancyService.Update(model); if (files != null) { //string s = objTenancyService.Getid(); string s = Convert.ToString(model.TnID); string strtext = "Tenancy"; foreach (HttpPostedFileBase file in files) { if (file != null) { string filename = System.IO.Path.GetFileName(file.FileName); string folderPath = Server.MapPath("~/UploadedDocs/") + strtext; // obj.EmpId = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString()); string destinationPath = folderPath; string employeeFolderPath = destinationPath + "/" + s; // create folder if it is not exist if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); if (!Directory.Exists(employeeFolderPath)) { Directory.CreateDirectory(employeeFolderPath); // create emp id folder of not exist } } else { if (!Directory.Exists(employeeFolderPath)) { Directory.CreateDirectory(employeeFolderPath); // create emp id folder of not exist } } destinationPath = employeeFolderPath; /*Saving the file in server folder*/ //file.SaveAs(Server.MapPath("~/Images/" + filename)); string fileNewName = Guid.NewGuid() + Path.GetExtension(file.FileName); file.SaveAs(Path.Combine(destinationPath, fileNewName)); objTenancyItem.UpdatedBy = uid; objTenancyItem.UpdatedDate = System.DateTime.Now; objTenancyItem.TenId = Convert.ToInt32(s); objTenancyItem.FileUrl = Path.Combine("/UploadedDocs/" + strtext + "/" + s + "/", fileNewName); objTenancyItem.FileName = Path.GetFileNameWithoutExtension(file.FileName); objTenancyService.Save(objTenancyItem); //string filepathtosave = "Images/" + filename; /*HERE WILL BE YOUR CODE TO SAVE THE FILE DETAIL IN DATA BASE*/ } } } return(RedirectToAction("Edit", new { @menuId = model.Viewbagidformenu })); }
public DirectTestableTenancyService(TenancyService tenancyService, IOpenApiContext openApiContext) { this.tenancyService = tenancyService; this.openApiContext = openApiContext; }